Shane LeBlanc
Shane LeBlanc

Reputation: 2643

HTML5 vs. jQuery Validate (For Inputs...)

Seems to me for simple forms that only require the user to ensure a field contains data or contains an email address that HTML5 works great. Would it be fine to get rid of jQuery validate or would there be any reason to use both?

I'm using ASP.NET MVC and learning as I go. I assume that adding a DataAnnotation to a Model Property and using @Html.ValidationMessageFor is what throws the jQuery validation message on there. I'm wondering if it would be fine to remove jQuery Validate as well as @Html.ValidationMessageFor and just use HTML5 input attributes such as type="email" or even required="required", even pattern="myregexhere".

Just wondering what everyone else is doing I guess.

Upvotes: 2

Views: 2244

Answers (3)

gdoron
gdoron

Reputation: 150253

If you remove DataAnnotation you remove the server side validation. BAD IDEA.
You can disable client-validation in the web.config.

You still have to make sure you have server-side validations!
javascript and HTML5 validation can be easily disabled.

And to your question... Most of modern browser still do not support HTML5, so wait a few years.

Upvotes: 2

Rajeev Nair
Rajeev Nair

Reputation: 759

As of now HTML5 is still catching up and not supported by all versions of all browsers... So I would advice you to use HTML5 along with jQuery. Also use modernizr for checking whether the browser supports HTML5.

Upvotes: 2

DA.
DA.

Reputation: 40671

Full HTML5 support is still a crapshoot, at best. Especially once you start working with all the variations of mobile (Android is disappointingly sporadic when it comes to HTML5 support).

I'd stick with jQuery for a while yet.

Upvotes: 3

Related Questions