spo,
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.js"></script>
<script>
$.validator.setDefaults({
submitHandler: function () {
alert("submitted!");
}
});
$.validator.addMethod("minlenghtphone", function (value, element) {
return value.replace(/\D+/g, '').length > 10;
},
" Маловато циферок будет!");
$.validator.addMethod("requiredphone", function (value, element) {
return value.replace(/\D+/g, '').length > 1;
},
" Заполните это поле!!!");
$(function () {
$("#commentForm").validate({
rules: {
phone: {
requiredphone: true,
minlenghtphone: true
}
}
})
});
</script>
</head>
<body>
<form class="cmxform" id="commentForm" method="get" action="">
<fieldset>
<p><input class="left" id="phone" name="phone"></p>
<p>
<input class="submit" type="submit" value="Submit"/>
</p>
</fieldset>
</form>
</body>
</html>