Number check
Create a webpage with a text box to enter a number. Write javascript code to validate the following: Check that the entry is a number, it’s length is 2. Show messages appropriately. Use the javascript code below as help.
var myNum = 0;
myNum=document.myForm.Num.value;
function checkNum(){
if (isNaN(myNum)){ //check to see it is a valid number ie. not string etc.
// show message box to say it is not a number
}else if(myNum.length!=2){
// show message box to say it needs to bet 2 digits long
}else {
// show message box to say all ok!
}
}

You need to log in or create an account to submit code!











