Wednesday, October 28, 2015

How to validation mobile number/phone number Numeric character Only in jQuery ?

In this below script, validation mobile number/phone number Numeric character Only in jQuery

validation mobile number/phone number Numeric character Only in jQuery
In this post , phone number validation in Javascript/Jquery validation
this field only allows numeric characters only.

1.When key is down not allow to enter any alphabet characters.

HTML:

<input type="text" title="num_Phone" id="txtphone"/>

JQuery:


$(document).ready(function () {

  $('input[title="num_Phone"]').bind("keydown", function (event) {
    if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
         
            (event.keyCode == 65 && event.ctrlKey === true) ||

     
            (event.keyCode >= 35 && event.keyCode <= 39)) {
         
              return;
        } else {
         
            if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) {
                event.preventDefault();
            }
        }
   });
});

2 comments:

  1. hello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community. Ben Luker

    ReplyDelete
  2. I got what you mean , thanks for posting .Woh I am happy to find this website through google. Ben Luker Scarborough

    ReplyDelete