开发者

HTML5 on older browsers?

I'm working on a page and I'd like to use HTML 5's setCustomValidity. It's easy enough to test if the browser supports it:

var inpt = document.getElementsByTagName("input")[0]; // etc.
if(typeof(inpt.setCustomValidity) != 'function')
  // workaround here

But I'm not sure if there's any reasonable way to deal with this. Sure, I can write a setCustomValidity function in that case, but it won't have the context (right?) to deal with the 开发者_Python百科event. Unless maybe I have functions call it with their own names?

If there's a library that handles this (Modernizr etc.) that would be great. If there's a good workaround I'd be happy to use that.

I have some ugly hacks in mind but I'd prefer to do this the right way if possible, whatever that might be.


This might be what you are looking for if you don't mind using jQuery: http://afarkas.github.com/webshim/demos/index.html

Fallback for form validation in browsers that don't support them: http://afarkas.github.com/webshim/demos/demos/webforms.html


I've heard great things about Modernizr and based on the attention its received I would definitely say give it a try.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜