Jquery: Validate the mobile number field.


Hi,

Below is the very simple code which is capable to validate the mobile number field on any .net form.

jQuery(document).ready(function () {
jQuery(“#btnChangeNumber”).click(function () {
var mobileNo = jQuery(“#txtNewMobileNumber”).val();
if (mobileNo == “”) {
alert(‘Please enter mobile number.’);
return false;
}
else {
var rege = /^[0-9\+\-\(\)\s]*$/;
if (!rege.test(mobileNo)) {
alert(‘Please enter valid mobile number.’);
return false;
}
}

});
});

Enjoy 🙂 !!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s