这是我的表单和验证jQuery,但是在UI中这个显示在文件上传(倍数)中的menagem“输入不超过3个字符。”。我认为问题是文件Field中的属性maxlength="3"
。
我如何删除此字段的验证?
<table cellpadding="0" cellspacing="0" class="main_table">
<tr>
<td class="label">@Resources.Registo.nome</td>
<td>@Html.TextBox("FullName", (Model != null ? Model.FullName : string.Empty), new { @class = "width250" })
@Html.ValidationMessageFor(model => model.FullName)</td>
</tr>
<tr>
<td class="label">@Resources.Registo.email</td>
<td>@Html.TextBox("Email", (Model != null ? Model.Email : string.Empty), new { @class = "width250" })
@Html.ValidationMessageFor(model => model.Email)</td>
</tr>
<tr>
<td class="label">@Resources.Registo.exemploFotos</td>
<td><input type="file" name="fileUpload" class="multi" accept="jpeg|jpg" maxlength="3" /></td>
</tr>
<tr><td colspan="2"><a class="button" onclick="$('#FormToValidate').valid() == true ? get_form(this).submit() : false" id="validateAndSubmitBtn" ><span>@Resources.Global.btnSubmit</span></a></td></tr>
</table>
$().ready(function () {
// validate signup form on keyup and submit
$("#FormToValidate").validate({
rules: {
FullName: {
required: true
},
Email: {
required: true,
email: true
}
},
messages: {
FullName: {
required: "@Resources.Registo.requiredFullName"
},
Email: {
required: "@Resources.Registo.requiredEmail",
email: "@Resources.Registo.emailValid"
}
}
});
});
答案 0 :(得分:2)
尝试ignore
参数:
$("#FormToValidate").validate({
rules: {
FullName: {
required: true
},
Email: {
required: true,
email: true
}
},
messages: {
FullName: {
required: "@Resources.Registo.requiredFullName"
},
Email: {
required: "@Resources.Registo.requiredEmail",
email: "@Resources.Registo.emailValid"
}
},
ignore: "input[type='file']"
});
如果您愿意,可以使用任何有效的jQuery选择器。