我正在尝试验证位于以下位置的表单:http://jsfiddle.net/PEmFH/8/我想在onfocusout上验证(每次用户离开字段时验证)。由于某些原因,它无法工作。
请在此处找到更新的小提琴:http://jsfiddle.net/PEmFH/11/
发布于 2013-09-30 06:48:48
您应该使用" element“方法,如果元素有效或不是http://jqueryvalidation.org/Validator.element/,则返回true或false
这是我解决问题的方法:
$.each($('#form input[type="text"], #form textarea'), function(index, control) {
$(control).focusout(function() {
if ($('#form').validate().element(this)) {
//Code for show a valid message or remove a invalid message
} else {
//Code for show a invalid message
}
});
});发布于 2014-10-17 12:46:32
这可能也会有帮助
//This is used to validate the Length Exceeded to Account number text box.
$('#AccountName').focusout(function () {
var currentVal = $.trim($('#AccountName').val()).toLocaleLowerCase().length;
if (currentVal > 50) {
alert("Length Exceeded");
return false;
}
});https://stackoverflow.com/questions/10226583
复制相似问题