Home > Web Front-end > JS Tutorial > body text

Sharing of usage examples of isNAN()

零下一度
Release: 2017-07-02 09:21:22
Original
1501 people have browsed it
<!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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template