需要HTML5输入 - 如何禁用 [英] HTML5 input required - how to disable

查看:120
本文介绍了需要HTML5输入 - 如何禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JQuery Validate拦截所需的属性,例如。

JQuery Validate intercepts the required attribute e.g.

<input type="text" required />

这将强制客户端验证该字段,这很好。现在这也是HTML5规范的一部分,并且导致支持它的浏览器即使禁用JavaScript也会显示验证消息。

This will force client side validation of the field which is great. Now this also is part of the HTML5 spec and causes browsers that support that to show validation messages even if JavaScript is disabled.

在我的应用程序中,我已经构建了服务器端验证我很满意,所以我想停止这种行为。所以我的问题是如何禁用此HTML5表单验证?

In my application I have already built the server side validation which I am happy with so I want to stop this behaviour. So my question is how can you disable this HTML5 form validation?

更新
似乎有些混乱,基本上我是很高兴JQuery验证解释那个和验证解雇是很好的。但是,如果用户禁用了JavaScript,我希望验证回退到我已编写的服务器端验证。但是,因为JQuery Validate和HTML5共享相同的标记,所以它不提交表单,而是显示我希望禁用的HTML5验证消息。这是否有意义?

Update There seems to be some confusion, basically I am happy with the JQuery validate interpreting that and the validation firing that is great. However, should a user have JavaScript disabled I want the validation to fall back to the server side validation that I have already written. However, because JQuery Validate and HTML5 share the same mark up it is not submitting the form but rather showing the HTML5 validation messages which is what I wish to disable. Does this make sense?

推荐答案

在表单对象中添加novalidate参数以停止浏览器验证表单。

Add novalidate parameter in form object to stop browser validating the form.

<form action="test.do" novalidate>
   <input type="text" required />
</form>

这篇关于需要HTML5输入 - 如何禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆