I need a bit of help here I need a perfect satisfying regexp for all indian phone numbers at current a regexp which will validate every indian phone number.
function checkemailandphone() {
var emailandphone = document.getElementById("emailandphone").value;
var email = /[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/g;
var phone = /^[6-9]\d{9}$/g;
if(emailandphone.match(email)) {
if(emailandphone){
$.ajax({
type: 'post',
url: 'emailcheck.php',
data: {
email:emailandphone,
},
success: function (response) {
if(response == "OK"){
$("#email").css({'background-color': 'lightgreen'});
var emailandphonevalid = true;
} else {
$("#email").css({'background-color': 'lightgray'});
var emailandphonevalid = false;
}
}
});
}
} else if(emailandphone.match(phone)) {
if(emailandphone){
$.ajax({
type: 'post',
url: 'phonecheck.php',
data: {
phone:emailandphone,
},
success: function (response) {
if(response == "OK"){
$("#email").css({'background-color': 'lightgreen'});
var emailandphonevalid = true;
} else {
$("#email").css({'background-color': 'lightgray'});
var emailandphonevalid = false;
}
}
});
}
} else {
$("#email").css({'background-color': 'lightgray'});
var emailandphonevalid = false;
}
}
The reason is quite weird but i need a code such that if a user gives input which has +91 added the expression must ignore it cause its already indian number basically there must be no errors in validation.