Download

Get Loom

Validation

Validation

Validation.js will perform in the browser the same validations of the server side. It requires the locale-specific messages (usually retrieved though ResourcesAction).

$$('form')[0].bindValidations();

The library will validate the contents when the field loses focus, and if failed it will locate the error display component, display the error message and cancel the focus event. When displaying error messages, the field name will be extracted from the surrounding label, if any.

If javascript is off, the server will generate the exact same HTML structure, which makes it possible to set in the server an error message that is later cleared in the browser.

Input prompt

Loom includes its own implementation of the Input Prompt pattern. To use, include prompt.js and the following javascript snippet:

new InputPrompt($$('form')[0]);

To use InputPrompt and validations at the same time InputPrompt must be created after registering the validations.

loom.validation.options.useTitle = false; // to avoid messing with InputPrompt
$$('form').each(function(f) {
	f.bindValidations();
	new loom.ui.InputPrompt(f);
});