Jquery (js) validation For 10 Digit Mobile Numbers - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Jquery (js) validation For 10 Digit Mobile Numbers - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Monday, June 26, 2017

Jquery (js) validation For 10 Digit Mobile Numbers

Jquery (js) validation For 10 Digit Mobile Numbers




After Testing All Answer not getting success . Some times input take alpha character also.
Here is the last full working code With Only number input also keeping in mind backspace button key event for user if something number is incorrect.

html : 

<input name="phone" id="phone" placeholder="Mobile Number" class="form-control" type="number" required>

Js :

<script>
$("#phone").keydown(function(event) {
k=event.which;
if((k>=96 && k<=105) || k==8)
{
     if($(this).val().length==10)
     {
         if(k==8)
         {
             return true;
         }
         else
        {
             event.preventDefault();
             return false;

         }
    }
}
else
{
     event.preventDefault();
     return false;
}

});
</script>

No comments:

Post a Comment

Post Top Ad