Thursday, 28 December 2017

Validate 10 Digit Phone Number


Enter Phone Number :

Code

<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <title>Girfa : Phone number validate</title>

    <script>
        function isNumberKey(evt) {
            if ($("#txtPhone").val().length < 10) {
                var charCode = (evt.which) ? evt.which : event.keyCode
                if (charCode != 46 && charCode > 31
                  && (charCode < 48 || charCode > 57))
                    return false;

                return true;
            }
            else
                return false
          
        }
      
    </script>
</head>
<body>
    Enter Phone Number :
    <input type="text" id="txtPhone" onKeyPress="return isNumberKey(event)" />
    <input type="button" value="Validate" />
  
</body>
</html>