Home  >  Article  >  Web Front-end  >  Sharing of usage examples of isNAN()

Sharing of usage examples of isNAN()

零下一度
零下一度Original
2017-07-02 09:21:221507browse
<!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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn