cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Maukisch" <jmauki...@s-und-n.de>
Subject CForms fd:javascript validation problem (validating two widgets against each other)
Date Mon, 12 Jul 2004 07:39:52 GMT
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message