简体   繁体   English

DIFF。 在HTML5中必需与jquery验证插件中必需之间

[英]Diff. between required in HTML5 and required in jquery validation plugin

I use jquery validation plugin for validation.all works perfect. 我使用jquery验证插件进行验证。一切正常。
first i clarify some things: 首先,我澄清一些事情:
(1) first i use required in textbox (not added jquery.js and jquery.validate.js), it works perfect. (1)首先,我在文本框中使用必需的(未添加jquery.js和jquery.validate.js),它可以完美工作。

 <input id="cname" name="name" type="text" required/>

(2) then i add jquery validation files and in textbox i already include required tag. (2)然后我添加了jquery验证文件,并且在文本框中我已经包含了required标记。 it is also work. 这也是工作。

first quetion :

The required tag is same for HTML5 and jquery validation (see example here) , so how they identify it and what is the diff. HTML5和jquery验证required标签相同(请参见此处的示例) ,因此它们如何识别它以及差异是什么。 between it and which one is finally work? 在它和哪个终于可以工作之间?

another quetion (only for jquery validation):

if i add class="required" in textbox the jquery validation is still work 如果我在文本框中添加class="required" ,则jQuery验证仍然有效

<input id="cname" name="name" type="text" class="required"/>

and also work for 并为

<input id="cname" name="name" type="text" required/>

so what is the diff. 那么差异是什么。 between this two lines and why jquery validation is work in both case? 在这两行之间,为什么在两种情况下都可以使用jquery验证?

Thanks in advance. 提前致谢。

HTML5 validations are dependant on browser. HTML5验证取决于浏览器。 but if browser does not support html5 validation then you will need jquery validation to work there. 但是如果浏览器不支持html5验证,那么您将需要jquery验证才能在此处工作。

So, I would say, for now use jquery validation, and do not trust on html5 validation. 因此,我要说的是,现在使用jquery验证,并且不要相信html5验证。 because not all browser support this. 因为并非所有浏览器都支持此功能。

see this, which browser support html5 validation 看到这个,哪个浏览器支持html5验证 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM