<Html>
<Head>
<Title> determine whether it is a number or space </title>
<Script type = "text/javascript" src = "jquery. min. js"> </script> // It doesn't matter whether the script is available or not.
<Script type = "text/javascript">
Function check_num () // create a function
{
Var Num = document. getElementById ("num"). value; // obtain the value (id = num)
If (isNaN (Num) | Num = "" | Num. substring () = 0) // note that the substring function is used to determine the space
{
Alert ("do not enter non-numbers ");
Return false;
} Else {
Alert ("correct ");
}
}
</Script>
</Head>
<Body>
Enter a number: <input type = "text" id = "num" name = "num" value = "">
<Input type = "submit" value = "submit" o ~ N ~ C ~ L ~ I ~ C ~ K ~ = "Check_num"> // here it is actually onclick, but it cannot be written.
</Body>
</Html>
This article is from the "networkapple" blog