Making a simple converter for convert a integer (1 - 99) to time in (1 - 60 minutes)
The formula works perfect, and converts 'on-the-fly', but i have problems with the error handling. When someone type '0' the first time after the webpage loaded then shows a notice, but when after a few converts and type '344' then the notice doens't showing anymore.
How can show the notice every time a number <= 0 OR number >= 100 OR isNaN(number) ?
The Javascript code:
<script>
function MinutesConverter(valNum) {
var x, notice, displayminutes
x = document.getElementById("inputnumber").value;
notice = document.getElementById('notice');
displayminutes = document.getElementById('minutes');
outputMinutes = document.getElementById("outputMinutes");
if ( isNaN(x) || x <= 0 || x >= 100 ) {
notice.innerHTML = "Voer een geheel getal in tussen 0 en 100";
} else {
notice.style.display="none";
displayminutes.innerHTML="minuten";
outputMinutes.innerHTML="";
outputMinutes.innerHTML=Math.round((valNum/100)*60);
}
}
</script>
And that's the experimental static webpage.
Aucun commentaire:
Enregistrer un commentaire