regex
Валидация тел (три блока по 4 цифры)
$('input[name^=phone1]').keyup(function(e){
validateFieldPhone($(this));
});
/*
* Validate one tel field.
* @param inputField
* @return true/false
**/
function validateFieldPhone(inputField) {
var regexPhoneField=/^[\d]{0,4}$/; /* only digits, max 4 digits*/
var text = inputField.val();
if (regexPhoneField.test(text)) {
inputField.parent().css('border','');
return true;
} else {
inputField.parent().css('border', '1px solid red');
return false;
}
}
$('input[name^=phone1]').keyup(function(e){
validateFieldPhone($(this));
});
/*
* Validate one tel field.
* @param inputField
* @return true/false
**/
function validateFieldPhone(inputField) {
var regexPhoneField=/^[\d]{0,4}$/; /* only digits, max 4 digits*/
var text = inputField.val();
if (regexPhoneField.test(text)) {
inputField.parent().css('border','');
return true;
} else {
inputField.parent().css('border', '1px solid red');
return false;
}
}