Followers

Wednesday, February 04, 2009

Prototype Form Validation

Tags: prototype, validation, dhtml

Utilizing DHTML abilities is one of the trendy features that when used with AJAX, you get to claim using some "buzz words" technology!

What a buzz word could be related to Ajax and DHTML?
as you might figured out already, Web 2.0!

Many web applications are becoming more user friendly as they are employing the DHTML technique but with a lot of work being done on the CLIENT side to validate user's input and saving a round-trip to the server for validation. Then there comes the need for a Javascript framework that makes controlling DHTML an ease of mind.

Prototype is one of the most known javascript frameworks, and is being used in different sites in combination with Sscriptaculous (mainly to add effects and animations). However, other useul extensions are available, Easy Field Validation is one of the most useful ones, and a must for any website utilizing forms and inline-edit-boxes.

The website for the script is here:
http://tetlaw.id.au/view/javascript/really-easy-field-validation

it has a demo, documentation, and other scripts.

Utilizing the script is very easy, althuogh mentioned in the main website, I will put this as a simple example:

excerpt form.html file:




<script src="prototype.js"></script>

<script src="effect.js"></script>

<script src="validation.js"></script>

:

:



<form id="'test_form'" action="'#'">

<input name="'name'" class="'required'">

<input name="'email'" class="'required">

<input type="'submit'" value="'Submit'">

</form>

:

:

<script>

new Validation(test_form, {onSubmit:false,stopOnFirst:true, immediate : true});

</script>

and you are using a very useful javascript extension!!

Enjoy.

About Me

My photo
Chicago, IL, United States
Creativity enthusiast ... Worked as web based application developer for more than 10 years using cgi, asp, php, asp.net server scripting languages in addition to JavaScript and recently glowing frameworks such as prototype, scriptaculous, jquery, mootools.. working on enhancing managerial skills and looking forward for a good position ;)