开发者

Are the HTML5 form attributes produced by MVC3 unobtrusive validation okay?

I have been having a look at MVC3 Unobtrusive Validation.

Attributes such as these are attached to form input elements:

data-val="true"                        //dec开发者_StackOverflow中文版lares that the element should be validated
data-val-required="this field is required"    // required constraint + error message 
data-val-number="this field must be a number"     //number constraint + error message
data-val-range="this number must be in the range 1 to ten"  // range constraint + error message 
data-val-range-max="10"  //range max value 
data-val-range-min="1"   //range min value

The blog posts I have read about MVC3 unobtrusive validation say that it is valid HTML5. However I have had a look in the W3C HTML5 spec and I don't see these attributes there.. http://www.w3.org/TR/2011/WD-html5-20110525/

I like the Idea of what these attributes do, enabling client side jQuery validation. But are they valid HTML5? Or will they cause problems in browsers and for search engines?


They're data attributes. Yes, they're valid HTML5:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜