..


Sponsored Links

Validate form with LiveValidation

Article written by John Belelli
Page 1 of 6

LiveValidation is a simple JavaScript library that allows you to perform client-side validation of data entered by users within the modules (forms).

Through the functions of this library, you can validate any form quickly and easily, just by writing a few lines of code. All this of course is released under open source license.
The official home page from which you can download the library and access to official documents, is livevalidation.com

The library is equipped with a set of methods that solve the most frequent series of validation, but you can also create customized validation by simply combining the tools offered by the library.

LiveValidation is available in two versions:

  • a stand-alone;
  • and one based on the prototype.
Both, of course, are fully compatible with most modern browsers.
In this article we will build the standalone version, which can be used safely with other libraries or frameworks.

To include the library will be sufficient to include it in our pages in HTML using JavaScript outside of the usual reminder:

 



 <script type="text/javascript" src="livevalidation_standalone.js"> </ script>

 
Before seeing the examples and their respective code, it is important to remember that the validation is carried out by LiveValidation it is a client-side validation, so it replaces the server-side validation, which must always be present in order to avoid inconsistent or incorrect data !
LiveValidation must therefore be considered as a part of (important) of a larger work of verification and control of data passed as input by users.

In general, the validation of a field is done by creating an object LiveValidation, who does nothing but select the field to be validated by ID assigned to it:

 



 var element = new LiveValidation ("elemento_da_validare");

 
You can also pass other parameters in the construction of the object as, for example, a message that shows the correct validation of the object or the wait time (in milliseconds) to start the validation (after the user has stopped typing the text). Let's look at an example:





 var element = new LiveValidation ("elemento_da_validare", {



  



 validMessage: "Compiled successfully!"



  



 wait: 500







 });



Below a picture with two examples of validation messages:

In the same category ...
E-Learning
CSS (Course) CSS (Course)
Web Design and Accessibility according to W3C CSS and XHTML. Starting from 29 €.
HTML (Course) HTML (Course)
The markup language for the Web from 29 €.
Javascript (Course) Javascript (Course)
Complete guide to client-side scripting. From 39 €.
Sponsored Links