简体   繁体   中英

Diff. between required in HTML5 and required in jquery validation plugin

I use jquery validation plugin for validation.all works perfect.
first i clarify some things:
(1) first i use required in textbox (not added jquery.js and jquery.validate.js), it works perfect.

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

(2) then i add jquery validation files and in textbox i already include required tag. 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. 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

<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?

Thanks in advance.

HTML5 validations are dependant on browser. but if browser does not support html5 validation then you will need jquery validation to work there.

So, I would say, for now use jquery validation, and do not trust on html5 validation. because not all browser support this.

see this, which browser support html5 validation 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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