1

我有以下 HTML:

    <form action="/User/Account/Register" class="form" method="post">
            <input name="__RequestVerificationToken" type="hidden" value="kq_5caRv7pZxBPgvvBiwHzNeQd_V8MvPzr9k85FsDWdhDmBh3yCq5JmofXpqxyhVcWWBfjYuKirpYfoWd_dor_VlpxqAb0AmN4sKSVbDJS1cDWwhI9xodugz-SKaoxmba-ukOw2" />


            <div data-valmsg-summary="true"></div>

            <div id="input-fields">
                <div>
                    <input data-val="true" data-val-required="The User name field is required." id="UserName" name="UserName" type="text" value="" />
                </div>
                <div>
                    <input data-val="true" data-val-length="The Password must be at least 6 characters long." data-val-length-max="100" data-val-length-min="6" data-val-required="The Password field is required." id="Password" name="Password" type="password" />
                </div>
                <div>
                    <input data-val="true" data-val-equalto="The password and confirmation password do not match." data-val-equalto-other="*.Password" id="ConfirmPassword" name="ConfirmPassword" type="password" />
                </div>
            </div>
            <button type="submit" class="white-gradient glossy">Register</button>
        </form>

但是,当我单击“注册”时,它不会执行我期望的任何检查,并且表单提交时没有任何问题。

有人可以告诉我我做错了什么吗?

4

1 回答 1

1

这是因为 data-val, data-val-required... 不是 HTML5 输入标签的属性。

请看这个:

HTML5 表单添加、验证

于 2013-09-22T03:53:51.147 回答