cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Artur Bialecki" <ar...@digitalfairway.com>
Subject RE: Logging and Form Validation
Date Fri, 07 Jun 2002 21:13:35 GMT

This is what we do for client side validation.
WARNING: requires javascript but my clients are not
"regular" web users.

For my app I provide validation in my XSP, eg:
  <validators>
    <ruleset id="username">
      <rule name="regEx" msg="- User Name must be alphanumeric. Valid characters: 0-9,
a-z, A-Z, _">
       <regex>^$|^[0-9a-zA-Z_]+$/ig</regex>
      </rule>
      <rule name="required" id="OEM-055" msg="User Name is required"/>
    </ruleset>    
    <ruleset id="email">
      <rule name="regEx" msg="- Email address must be in following format: yourname@yourdomain.com">
       <regex>^$|^[0-9a-zA-Z.,_\\-]+\\@[0-9a-zA-Z._\\-]+\\.[a-zA-Z]+$/ig</regex>
      </rule>
    </ruleset> 
   </validator>

so for each from field that needs to be validated I have 
<ruleset> with id of the form field and one or more rules.
I also provide validation template that reads the /page/validators
and creates validateAndSubmit() javascript function that
validates all fileds specified in XSP.
Form filed name must match validator names but that's easy.
I define validators in XSP since some of them are based
on DB queries.

This works great for us.

We also validate on server side with automagic annotation
of errors and from field repopulation since not everything
can be validated on the client side (eg: does city Bumbomie
exsits?) so I our clients ask for support for javascripless
browers (which they wont) it will still work.

Just my 2 cents.

Artur....


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message