On 12/05/2012 09:54, coder wrote:
I have a very simple html5 contact form which I'd like to keep that way.
However, the 'pattern' attribute isn't recognised by IE and I feel that
it surely must be possible to just use a bit of modernizr to make it
work. Example is:

<label for="email" accesskey="E">Email</label>
<input name="email" id="email" placeholder="Enter your Email Address"
required type="email">

I'm not a javascript person and I wonder if it is possible to just use a
bit of extracted code from jquery/modernizr without having to link to
the whole script, much of which is surplus code - i.e., just put a small
amount of script right in the page.

Modernizr doesn't polyfill/patch missing functionality (with the exception of a few minor things like making the new HTML5 semantic elements "work" in IE, for instance). Modernizr is primarily concerned with detecting support for features.

To patch in the functionality you're after, you'd need to conditionally load a full-on JS client-side form validation plugin/solution (and of course, you're still validating on the server as well, right?). Basically (in pseudocode), on load you want to:

- check via modernizr if native client-side form validation is available and working
- if it isn't, add a <script> that loads the JS-based form validation

Incidentally, if you're already specifying type=email, why are you also adding a pattern attribute? type=email is, effectively, a pre-baked regular expression/pattern in the browser, so you shouldn't need the extra pattern...

Patrick H. Lauke
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]

www.splintered.co.uk | www.photographia.co.uk
http://redux.deviantart.com | http://flickr.com/photos/redux/
twitter: @patrick_h_lauke | skype: patrick_h_lauke

List Guidelines: http://webstandardsgroup.org/mail/guidelines.cfm
Unsubscribe: http://webstandardsgroup.org/join/unsubscribe.cfm
Help: memberh...@webstandardsgroup.org

Reply via email to