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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:57:01
Script start
Timing: Jan 18 2025 04:57:01
Module start 'layout'
Timing: Jan 18 2025 04:57:01
Module start 'content'
Timing: Jan 18 2025 04:57:01
Module end 'content'
Timing: Jan 18 2025 04:57:01
Script end

Main resources:

Total runtime0.7053 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 589.0313152.6250
Module start 'layout' 0.00480.0027 741.656339.4453
Module start 'content' 0.00760.6961 781.1016441.0938
Module end 'content' 0.70370.0016 1,222.19538.3203
Script end 0.7052  1,230.5156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4417160.0002
Check MTime0.00130.1795160.0001
Mysql Total
Database connection0.00060.090510.0006
Mysqli_queries0.661593.7883460.0144
Looping result0.00040.0540440.0000
Template Total0.670195.020.3350
Template load0.00230.320220.0011
Template processing0.667894.682320.3339
Template load and register function0.00020.024010.0002
states
state_id_array0.00230.319510.0023
state_identifier_array0.00080.119520.0004
Override
Cache load0.00180.2537120.0001
Sytem overhead
Fetch class attribute can translate value0.00060.082210.0006
Fetch class attribute name0.00080.110420.0004
XML
Image XML parsing0.00170.234510.0017
class_abstraction
Instantiating content class attribute0.00000.000720.0000
General
dbfile0.00330.4654160.0002
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs