On 15.07.2004 05:30, Adam Walsh wrote:
Hi,
I have a form with two fields in it, where at least one of the fields
must be filled in, and I've put a bit of javascript to check it in the
form definition:
<fd:field id="field1" required="false">
<fd:label>field 1</fd:label>
<fd:datatype base="string"/>
<fd:validation>
<fd:javascript>
if (widget.getValue() == null &&
widget.getParent().lookupWidget("field2").getValue() == null)
{
var i18nMessage = new
Packages.org.apache.cocoon.forms.util.I18nMessage("someErrorMsg", "tt");
widget.setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError(i18nMessage));
return false;
}
What about:
else {
widget.setValidationError(null);
> return true;
}
</fd:javascript>
</fd:validation>
</fd:field>
<fd:field id="field2" required="false">
<fd:label>field 2</fd:label>
<fd:datatype base="string"/>
</fd:field>
This seems to work ok, except that if it fails once it doesn't seem to
recognise new values for field2 when the form is submitted again. It
seems to always think that field2 is empty even when it's not. Is this a
bug, or am I doing something stupid? Is there a better way I should be
doing this validation?
Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]