Hi,

I have two field widgets (datatype date) in my form
and I want to validate them against each other with
some javascript code.

The validation rule for the first widget is, that the
date must be after today and the js-code looks like this:
var error = true;
var value = widget.value;
var today = new Packages.java.util.Date();
if(today.after(value)) {
        widget.setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError     ("errormsg",
true)); 
        error = false;                          
}                               
return error;           

The date of the second widget must be after the date of the first widget.
The js-code looks like this (it might work with fd:assert as well, but it
should not matter atm);
var error = true;
var value = widget.value;
var parent = widget.getForm();
var widget1 = parent.lookupWidget("widget1");                   
var value2 = widget1.getValue();
if(value.before(value2)) {
        widget.setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError("errormsg",
true));                         
        error = false;
} 
return error;

The problem is that if the first widget is not valid and i want to validate
the second widget, the 
value of widget1 (widget1.getValue()) is always null.

The validation of the second widget works fine if the validation of the
first widget is ok.



Thanks for your help in advance,

kind regards
Jens


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to