jQuery <input> check whether a value is numeric or not

Introduction

Use the jQuery $.isNumeric() method to check whether a value is numeric or a number.

$.isNumeric() returns true only if the argument is of type number.

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery Find Entered Value is Numeric or Not</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $(document).ready(function(){
        $("button").click(function(){
            var inputVal = $("input").val();
           document.getElementById("demo").innerHTML = $.isNumeric(inputVal);
        });//from w  ww .j a va2  s. c o m
    });
</script>
</head>
<body>
    <p id="demo"></p>
    <form>
        <input type="text">
        <button type="button">Check</button>
    </form>
</body>
</html>



PreviousNext

Related