/*Validate Phone No*/
$('.valPhoneNo').blur(function(){
var phone = $(this).val();
phone = phone.replace(/D/g,'');
if(phone.length == 7){
var dispPhone = phone.slice(0,3) + "-" + phone.slice(3);
$(this).val(dispPhone);
} else if(phone.length == 10) {
var dispPhone = "(" + phone.slice(0,3) + ") " + phone.slice(3,6) + "-" + phone.slice(6);
$(this).val(dispPhone);
}
});
Javascript phone number validation script
Leave a reply