目前,我有以下自定义规则来验证表单的字段。
规则
$scope.validator = $("#frmPreregistration").kendoValidator({
rules: {
varifySsn: function (input) {
var ret = true;
if (input.is("[name=last4Ssn]") && $scope.Last4DigitsSsn != undefined ) {
ret = $scope.validateSsnLast4Digit();
}
return ret;
},
varifyDob: function (input) {
var ret = true;
if (input.is("[name=dob]") && $scope.DateOfBirth != undefined ) {
ret = $scope.validateDateOfBirth();
}
return ret;
},
varifyZipCode: function (input) {
var ret = true;
if (input.is("[name=zipCode]") && $scope.ZipCode != undefined ) {
ret = $scope.validateZipCode();
};
return ret;
}
},
messages: {
varifySsn: $scope.resources.SsnLast4DigitDoesNotMatch,
varifyDob: $scope.resources.DobNotMatchWithSelectedUserType,
varifyZipCode: $scope.resources.ZipCodeNotMatchWithSelectedUserType,
}
}).data("kendoValidator");
每当用户在$scope.validator.validate()
这导致在用户输入任何值之前触发所有字段的规则。
问题 我是否有可能一次运行特定的验证规则或运行特定字段的验证?
答案 0 :(得分:3)
您可以将validateInput
用于特定元素。
示例:强>
$scope.validator.validateInput($("input[name=dob]"));
隐藏无效邮件,您可以使用hideMessages
功能
$scope.validator.hideMessages();