他の投稿を読みましたが、送信時に必須フィールドの一部のみが検証されない理由がわかりません。クライアントのクライアント側が彼のスクリプトを検証するのを手伝っており、フォームが別の関係者に投稿されています。私のサーバー上: http://alluringassets.com/caitlin/projects/validationscript/index.html . イベントの日付に注目すると情報は検証されますが、注目せずに [送信] をクリックすると、プログラムは場所、グループの規模、イベントの日付を検証せず、上位のフィールドを検証します。何か案は?
$.validator.addMethod("groupMin", function(value) {
return $("#00NG0000008iHKH").val() >= 6;
}, 'Sorry, but we only handle groups of 6 or more.');
$.validator.addMethod("seoNO", function(value) {
return $("#00NG0000008iHKg").match(/SEO/g);
}, 'No thank you! We are not interested in Search Engine Optimization support.');
$.validator.setDefaults({
//submitHandler: function() {
//form.submit();
//alert("submitted!"); }
});
$().ready(function() {
var validator = $("#detailRequestForm").bind("invalid-form.validate", function() {
$("#summary").html("Your form contains " + validator.numberOfInvalids() + " errors. Please correct.");
}).validate({
rules: {
firstname: "required",
lastname: "required",
email: {
required: true,
email: true
},
company: {
required: true,
minlength: 2
},
'00NG0000008iHK7': {//Program Location
required: true,
minlength: 2
},
'00NG0000008iHKH': //Group Size
"groupMin",
'00NG0000008iHKR': {//Event Date
required: true,
minlength: 3
},
'00NG0000008iHKg':"seoNO",
},
messages: {
firstname: "Please enter your firstname",
lastname: "Please enter your lastname",
email: "Please enter a valid email address",
company: "We do not serve private groups. Sorry, we can't help you.",
'00NG0000008iHK7': //Program Location
"Where will the program be located?",
'00NG0000008iHKH':{//Group Size
required:"Please enter the number of members in the group.",
},
'00NG0000008iHKR': {//Event Date
required: "Please enter a date or TBA if you are unsure."
},
'00NG0000008iHKg': {//Comments
//required: "Please enter any comments or questions you may have."
}
},
errorElement: "em",
errorContainer: $("#warning, #summary"),
//highlight: function(label) {
//$(label).removeClass("success").addClass('error');
//},
//success: function(label) {
//label.text("ok!").empty().addClass("success");
//}
});
});