<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script> function myfunction() { var t=document.getElementById("demo2").value; if(t==""||isNaN(t)){ alert("不是数字"); } else return; } </script> </head> <body> <h1>我的第一个 JavaScript 程序</h1> <p id="demo">请输入数字。如果输入值不是数字,浏览器会弹出提示框。</p> <input type="text" id="demo2"> <button type="button" onclick="myfunction()">click</button> </body> </html>
The above is the detailed content of Sharing of usage examples of isNAN(). For more information, please follow other related articles on the PHP Chinese website!