gpt4 book ai didi

javascript - 使用 jquery 验证忽略字段文件

转载 作者:行者123 更新时间:2023-11-30 18:31:32 26 4
gpt4 key购买 nike

这是我的表单和验证 jQuery,但在 UI 中,这在文件上传(多个)中显示了 mensagem“输入不超过 3 个字符”。我认为问题出在文件字段中的属性 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"
}
}
});

});

最佳答案

试试忽略参数:

$("#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 选择器。

关于javascript - 使用 jquery 验证忽略字段文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9501605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com