-3
我有下面的jQuery代码来验证窗体。验证具有相同输入字段名称的表单?
function validateForm(){
$("input.field1").each(function(){
$(this).rules("add", {
required: true,
messages: {
required: "Required"
}
});
});
$("input.fieldTwo").each(function(){
$(this).rules("add", {
required: true,
maxlength: 12,
email: true
messages: {
required: "Enter email",
email: "Enter valid email",
maxlength: "Maximum 12 characters"
}
});
});
$("input.field3").each(function(){
$(this).rules("add", {
required: false,
maxlength: 12
messages: {
maxlength: "Maximum 12 characters"
}
});
});
$("input.field4").each(function(){
$(this).rules("add", {
required: false,
maxlength: 12
messages: {
maxlength: "Maximum 12 characters"
}
});
});
$("input.field5").each(function(){
$(this).rules("add", {
required: false,
maxlength: 12
messages: {
maxlength: "Maximum 12 characters"
}
});
});
return $("#myForm").validate({
onfocusout: function(element) { jQuery(element).valid(); }
});
}
但它总是给脚本错误说SyntaxError: missing } after property list
。
但我相信没有地方}是必需的。
我在这里失踪了吗?
谢谢!
你错过了逗号...这真的是这个地方吗? :) – Splendiferous
这个问题似乎是脱离主题,因为问题是一个类型错误 – iConnor