Computer Programming web Web programming Tips



JavaScript Form Validation Example.

By Sergey Skudaev


I used different methods for form validation. THis one I like the most. It takes all fields on the form and walk through.

To see source code, click on the webpage with right mouse button and select view source code.

I like this method, because it works even on fields created by cloning with javascipt. When you create an array of fields by clonning them with JavaScript, you cannot know index of the array for each field. It makes hard to write validate code by reference each field in the array. This method allows to validate all fields on the form. Just use name of the element to identify it.

JavaScript code for validation

HTML Form:

 

 

My eBooks on Amazon.com

US    UK    BR    CA
US    UK    BR    CA
US   UK   BR   CA