cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <>
Subject Definitive date validation in Cocoon forms?
Date Tue, 07 Aug 2007 13:50:06 GMT
I am really trying to get  handle how to effectively do date 
validation in Cocoon forms.
Step 1 is simply to see that the date is, in fact, a valid date.
The obvious (to me, anyway) approach would be to have a simple:
   <fd:failmessage>Not a valid date!</fd:failmessage>
But this does not exist, so...
Merico Raffaele proposed an approach using javascript: 
  var enteredValue = cocoon.request.get(widget.getRequestParameterName());
  var trimmedValue = enteredValue.replaceAll("\\s", "");
  if (!isDate(trimmedValue, "yyyy.M.d")) {
  var valError = new org.apache.cocoon.forms.validation.ValidationError("invalidDate");
  return false;

Andreas Hartmann's approach was to use formatting: 

<fd:datatype base="date">
 <fd:convertor type="formatting">
but found this lead to problems with values like
which is interpreted as
and results in the formatted value

My "ideal" would be to specify the format for the user,
such yyyy/MM/dd, and require them to enter ALL the values,
following which the date could be validated:
  Step 1: for plausibility and
  Step 2: for range, if needed (e.g. "after today", or "between 
    2006/11/20 and 2007/12/31)
otherwise, if entries such as 4/5/6 are allowed (which seems 
to be the case with formatter above), then a huge amount of
ambiguity is present.
Is there, in fact, a definitive way of doing server side date 
validation - preferably one that does not involve lots of 
customisation -  and can someone clearly lay out how to do it??
Much appreciated,

This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
CSIR E-mail Legal Notice 
CSIR Copyright, Terms and Conditions 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message