# HTML 5 forms for Rails A collection of Polyfills for using HTML 5 forms with the Rails asset pipeline. All credits, copyright etc. belong to the original authors of each polyfill library. [HTML5-Cross-Browser-Polyfills](https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills) The following polyfill libraries are currently included: * [HTML5Forms.js](https://github.com/zoltan-dulac/html5Forms.js) * [H5F](https://github.com/ryanseddon/H5F) * [HTML5-Form-Shim](https://github.com/dsheiko/HTML5-Form-Shim) * [jQuery HTML5 form](http://www.matiasmancini.com.ar/jquery-plugin-ajax-form-validation-html5.html) Components from the article [how-to-build-cross-browser-html5-forms](http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-cross-browser-html5-forms/) are also included as _html5forms.fallback_ Even [webforms2](https://github.com/westonruter/webforms2) is now included and should work with html5Widgets to display native javascript widgets ;) To enable Formdata for older browsers, the following libs are included: * formdata.js * jquery.form.js See [html5-formdata](https://github.com/francois2metz/html5-formdata) ### Install Simply add to Gemfile and bundle: `gem 'html5forms-rails'` If the polyfill library uses modernizr to detect HTML 5 feature availability: `gem 'modernizr-rails'` See [modernizr-rails](https://github.com/kristianmandrup/modernizr-rails) ## html5forms.fallback See [how-to-build-cross-browser-html5-forms](http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-cross-browser-html5-forms/) * colorpicker * spinner * placeholder To use the _jQuery UI_ components as fallback, please use the [jquery-ui-rails](https://github.com/joliss/jquery-ui-rails) gem ;) ### Configuration ```text //= require html5forms.fallback //= require ui.spinner //= require jquery.placehold //= require colorpicker ``` `*.min` versions are also included ;) In your asset `application.css` manifest file: ```css */ * require colorpicker * require ui.spinner */ ``` ## HTML5Forms.js [HTML5Forms.js](https://github.com/zoltan-dulac/html5Forms.js) is a JavaScript polyfill that implements a subset of the HTML5 Forms module in all browsers. The script will only add support for the different parts of the module when there doesn't exist a native implementation. HTML5Forms supports the following HTML5 input types: * range * date * datetime * datetime-local * week * color It also supports: * form validation (via "required" and "pattern" attributes) * the autofocus attribute (i.e. focusing on a particular form element onload) * the placeholder attribute (i.e. descriptive text of what should be in a form field) * the output tag (solves equations of form elements) * CSS styling of form validation states (simulates :invalid and :valid in unsupported browsers like IE9 and lower) * CSS styling of form elements that are not included in the CSS3 UI specification, but I think are useful for developers: - .wf2_isBlank, .wf2_notBlank – these classes are applied to form field when a form element is blank/not blank repectively. - .wf2_lostFocus -this class is applied to a form element when a form field loses focus. - .wf2_submitAttempted – this class is applied to a