cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Garulli <>
Subject Re: Client side validation
Date Thu, 25 Nov 2004 14:44:15 GMT
On Thu, 25 Nov 2004 13:33:17 +0100, oceatoon <> wrote:
> >> But then don't you have double validation ?
> >
> > Yes, server side validation must be always guarantee. Client side
> > validation is useful basically for two reasons:
> >
> > 1. avoid unnecessary server load
> > 2. some customer doesn't want page refresh. There are other techniques
> > to avoid page reload, but it's a little bit more complex...
> Yes, with CJS there wouldn't be long reloads, but many reactive validations
> and one longer send in the end. I'm curious of what you mean by more
> complex techniques to avoid reload ?
> Thanks, I guess double validation has to be then,
> will you publish your transformer to CJS ?

Yes, but I don't know where to post it. Current version of transformer
generates one function per widget. The transformer gets the "mode"
= form: checks all fields in one shot, generally in the submit button
= field: checks each field when the focus is lost, using onBlur()
event in javascript

Inside the function:

- if required='true', checks if the value is not null 
- if datatype=integer|long, checks the number
- if datatype=double|decimal, checks the number considering also the decimals
- if datatype=date, then checks the date format in the (optional)
format specified in fi:convertor/@pattern

After all single validate functions, the validate_form() function will
be generated with the call to each functions, aggregating the error
fields name in the array returned.

So you can customize the error management with a function like this:

function validate()
  var results = validate_form();
  var msg = "";
  for( var i = 0; i < results.length; ++i )
    msg += "\nError on filed: " + results[i];
  if( results.length > 0 )
    alert( "Error on validation:" + msg );

Please, tell me suggestion and improvement to insert at the fly.

> Thanks
> Tibor

Luca Garulli (member of - The XML business alliance) - Light ODBMS, All in one JDO solution

View raw message