我做了一个validate的验证,但是没有起作用,我怀疑是Id的问题,但是没有测出来,麻烦大家帮忙看看。。。
<script type="text/javascript">
$().ready(function () {
$("#setPersonForm").validate({
rules: {
Member_RegMobile: {
required: true,
maxlength: 11,
minlength: 11
},
messages: {
Member_RegMobile: {
required: "请输入手机",
maxlength: "手机长度应为11位",
minlength: "手机长度应为11位"
},
});
});
</script>
<div>
@using (Html.BeginForm("GeneralCompany", "Register", FormMethod.Post, new { @id = "setPersonForm" }))
{
<div id="TabbedPanels1" class="TabbedPanels">
<label class="la">手机号码: </label>
@Html.TextBoxFor(m => m.Member.RegMobile, new { @placeholder = "正确的手机号码", @autocomplete = "off", @class = "l_ipt" })
</div>
}
</div>
我用的是.net MVC框架和js验证,我感觉是Member_RegMobile 对应m => m.Member.RegMobile没有对应起,从而不识别???
[解决办法]
验证的是 Member.RegMobile
写成Member_RegMobile什么意思?