The following example shows a better method.
I. isNaN method:
IsNaN () indicates a non-number. If a number is input, false is returned. If the number is not input, true is returned.
[If it is null, true is returned. If it is null, true is returned for a vertex. If it is a combination of vertices, false is returned, indicating a number.]
Copy codeThe Code is as follows:
<Script language = "JavaScript">
Function testNan (){
If (isNaN ('xxx ')){
Alert ('true ');
} Else {
Alert ('false ');
}
}
</Script>
------------------------------- Example -----------------------------
<Html> <pead> </pead> <body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
2. Compare methods one by one.
For example:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <meta name = "Generator "CONTENT =" EditPlus "> <meta name =" Author "CONTENT =" "> <meta name =" Keywords "CONTENT =" "> <meta name =" Description "CONTENT = ""> </HEAD> <BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Conclusion: If the decimal point is always entered in method 2nd, the prompt is correct. But not in 1st. As long as you do not conform to the digit format, it won't let you pass.