错误放置默认样式

errorplacement default style

我用数据输入表单创建了一些页面 jsp。 一些页面已经定义了验证的功能:

<script>
$(document).ready(function() {
$("#newPassword").validate({
        rules : {
            password : "required",
            passwordConfirm : {
            equalTo : "#password"
            }
        },
        messages : {
            passwordConfirm : "<spring:message code='change.label.error.confirmPassword'/>"
        }
    });
});
</script>

在这种情况下错误是这样显示的:

我更希望看到它是由默认浏览器完成的:

我该怎么做?

"In this case the error is displayed in this way:"

这就是 jQuery 验证插件创建错误消息的方式。


".... as is done by the default browser:"

浏览器就是这样使用的HTML5 validation attributes to create the error messages


"I would rather see it as is done by the default browser: How can I do it?"

删除 jQuery 验证插件以允许浏览器默认 (HTML5) 接管。否则,您不能让浏览器在使用 jQuery 验证插件时使用 HTML5 验证,因为该插件会动态禁用任何 HTML5 验证并接管。