Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd prefer a library that reads its parameters from HTML5 attributes (such as required, maxlength, pattern, etc). That would bring support for client side form validation to browsers that don't natively support it. Ideally this would be as simple as loading a javascript file with <script> tags.

It would also be much easier to use, because there would be no API to "learn".



This is a great idea. It looks like there are at least two plugins already that claim to validate the new HTML5 attributes: [html5-form][1] and [h5Validate][2]

[1]: http://www.matiasmancini.com.ar/jquery-plugin-ajax-form-vali...

[2]: http://ericleads.com/h5validate/


Like how angularjs works with directives? In angular you can create your own directives (HTML elements, so to say). You can add attributes to these directives. In this directive simply check if the browser supports the HTML5 element. if(this_is_true): render_this_element() else: mimic_behaviour().


https://github.com/pags/fields.js

Give it a look. As you described, it simply parses standard input tag params, including HTML 5 types. It's my first attempt at anything like this, so be gentle.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: