Charles
Charles

Reputation: 11479

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

Upvotes: 4

Views: 3123

Answers (2)

fijter
fijter

Reputation: 18057

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

Upvotes: 3

MoarCodePlz
MoarCodePlz

Reputation: 5176

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

Upvotes: 1

Related Questions