Javascript examples for Number:isNaN
Check if a value is Not-a-Number with isNaN() function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function foo() {//from ww w . j a v a 2 s . co m var a = document.getElementById("inputField").value; if (isNaN(a)) { console.log("Must input numbers"); } else { console.log("its a number"); } } </script> </head> <body> <input id="inputField"> <button onclick="javascript:foo()">check if numeric</button> </body> </html>