function checkNumber(aNumber) {

if (aNumber > 0 && aNumber < 100) {

////////////////////////////////////////////////////

// If the number is greater than 0 and less than

// 100, pop up a “congratulations” message and return

// a value indicating success.

////////////////////////////////////////////////////

alert(“The number you specified is valid (it is between 0 and 100).”)

return true

}

////////////////////////////////////////////////////////

// Otherwise, the number is negative or over 100,

// so return a value indicating failure.

////////////////////////////////////////////////////////

else {

alert(“The number you specified is invalid (not between 0 and 100).

\nPlease try again.”)

return false

}

}

...

...

Please type in a number:

...

onClick=”checkNumber(document.myForm.inputNumber.value);”>

 


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments