<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en"
<TITLE> New Document </title>
<meta name= "Generator" content= "EditPlus";
<meta name= "Author" content= ""
<meta name= "Keywords" content= "",
<meta name= "Description" content= "";
<script>
Var i=0;//i indicates that the number of
function Checknum (obj) {
//Can be judged no more than 6-bit
if (i==6) {
alert ("Sorry! The number you entered is more than six digits ");
return false;
}
if (i==0) {
if (event.keycode== "0". charCodeAt (0)) {
Alert ("The first cannot be 0, please re-enter!") ");
return false;
}
}
/*if (event.keycode<48| | event.keycode>57) {
Alert ("You are not entering a number, please re-enter!");
return flase;
}*/
//If we can't remember 0->48,9->57, it can be as follows:
//Determine if the input is a number
if (event.keycode< ' 0 '. charCodeAt (0) | | Event.keycode> ' 9 '. charCodeAt (0) {
Alert ("You are not entering a number, please re-enter!");
return false;
//event.returnvalue=false;//This is limited to IE in
}else{
i++;
}
}
</script>
<BODY>
<!--When an event receives a false return value, it indicates that the behavior is discarded--
Please enter a six-digit number: <input type= "text" id= "Pagenow" onkeydown= "return Checknum (This)"/><!--Note that there will be a return value--
</BODY>
</HTML>
<!--
Note: The disadvantage here is that when you think you've lost a mistake, you want to delete the number you entered earlier.
-
Determines whether a number is entered in the input box