Forums / Suggestions / dojo - Client-side validation

dojo - Client-side validation

Author Message

Betsy Gamrat

Monday 10 December 2007 5:40:08 pm

I've been working with dojo (http://dojotoolkit.org/) for about a month and a half, and I really like it. I think it would integrate well into the attribute_view_gui templates, probably as an extension.

The value would be in using dojo to handle client-side validation to offload the server. Here's a sample:

	<div class="element">
	<label for="sFirstname">First name</label>
	<input type="text" name="sFirstname" id="sFirstname" 
		value="First"
		dojoType="dijit.form.ValidationTextBox"
		regExp="[A-Za-z\ ]{1,20}"
		promptMessage="First name" 
                                errorMessage="The first name is from 1 to 20 characters"
                                invalidMessage="Please enter 1 to 20 characters"
		maxlength="20" />
	</div>

dojo adds attributes to the input tag, and with a fair amount of javascript (which can be cached by the browser), does a great job with validation, and helping the user enter the data correctly.

To test the data in the above input, the following javascript could be used:

sF=dojo.ById('sFirstname');
if (!sF.isValid())
  alert(sF.errorMessage);

dojo is available on AOL's CDN.

* Code may have errors