Usage

The library introduces the global variable hyperform. You can let Hyperform take over a single form:

var $form = hyperform(document.forms[0]);

or all forms, current and future ones:

var $form = hyperform(window);

In the first case, Hyperform will only polyfill the elements currently available in the form. In the second case, the polyfills are applied to all current and future forms and input elements (via the element prototypes).

Hyperform returns a wrapper object. If you want to remove the extra functionality, call the wrapper’s destroy() method:

$form.destroy();

If you only need a certain feature, you can access it directly by name from the global hyperform object:

if (hyperform.willValidate(form.elements[0])) {
  var is_valid = hyperform.ValidityState(form.elements[0]).valid;
}

Configuration

Configure settings as second argument:

hyperform(window, {
  revalidate: 'onsubmit',
  validEvent: false,
});

The available settings are:


:gem: Next: HTML 5 API – how to use the HTML 5 form validation with Hyperform for fun and profit.