Description |
Indian mobile no. with country code as optional
example:--
function validate()
{
var filter1=/^((\+)?(\d{2}[-]))?(\d{10}){1}?$/,filter2=/^((\+)?(\d{2}[-])(\d{2}[-]))?(\d{8}){1}?$/;
var mobileNo=$("#mobileNo").val(),temp=0;
if (filter1.test(mobileNo)) {
//temp++;
}
if (filter2.test(mobileNo)) {
temp++;
}
if (temp>0) {
alert("Matched with given format!");
} else {
alert("Not Matched with given format!");
}
here mobileNo is an input filed in my html page.. you can use it as per your need.. |