简体   繁体   中英

What technology does HTML5 email input type use?

Question 1: I saw email input type in HTML5, works even if I disable my Javascript in Browser, Then what technology does it use to validate?

Question 2: Also, In the firebug profiler , I saw data-val-regex of ASP.NET , inturn calls Jquery , how the control is transferred to that ? That is data-val-regex is JQuery's feature or HTML's feature?

Reference :

<div style="width:255px; height: 30px; float:left;"><input data-val="true" data-val-regex="Please&#32;enter&#32;valid&#32;email&#32;id" data-val-regex-pattern=".+\@.+\..+" />

Answer 1 : This is a browser feature. Some browsers can read the type property of the input and behave accordingly. For example an iPad will show the numeric keypad for number input and a special keyboard which has the @ sign for the email input.

Answer 2 : This is a feature of the unobtrusive libraries from Microsoft. Basically those attributes (all beginning with data- ) are HTML5 valid attributes and are harvested when the page is displayed, then bridged over to the jquery validate by creating rules and methods. For a better explanation, you can have a look at one of my old answers on how to roll your own validation and will hopefully make things clearer.

Data- is a custom attribute in HTML5 spec

Custom data attributes are intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.

These attributes are not intended for use by software that is independent of the site that uses the attributes.

Every HTML element may have any number of custom data attributes specified, with any value.

http://www.w3.org/html/wg/drafts/html/master/dom.html#embedding-custom-non-visible-data-with-the-data- *-attributes

If you want to know more info http://html5doctor.com/html5-custom-data-attributes/

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