cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beya! <and...@jibeya.com>
Subject Re: Cocoon Forms - validating required fields
Date Tue, 16 Nov 2004 16:30:04 GMT
Mark,
try this:

<?xml version="1.0"?>

<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
<fd:validation>
   	<fd:javascript>
   		var success = true;
   		var password = widget.lookupWidget("password");
   		if (password.value == null) {
   			quantity.setValidationError(new 
Packages.org.apache.cocoon.forms.validation.ValidationError("Please 
enter password", false));
   			success = false;
   		}
   		return success;
   	</fd:javascript>
</fd:validation>

<fd:widgets>
     <fd:field id="password" required="true">
       <fd:label>Enter password:</fd:label>
       <fd:datatype base="string"/>
       <fd:validation>
         <fd:range min="5" max="9">
           <fd:failmessage>Please enter password.</fd:failmessage>
         </fd:range>
       </fd:validation>
     </fd:field>
</fd:widgets>

</fd:form>

regards


Andrew
On 16 Nov 2004, at 17:14, Mark Leicester wrote:

> Hi all,
>
> When a user leaves a required field blank, is there a way to generate a
> custom fd:failmessage for that specific field?
>
> For example: I have two required fields - username and password - both
> required. Say the user enters their username, but leaves the password
> field blank. I get the [general.field-required] message. How can I
> override this with a custom message saying "Enter your password!
> (please)". Must I resort to a custom Javascript handler?
>
> I've been out of active Cocoon development for nine months or so. It's
> great to be back - and to see how far flow and forms have come on. Nice
> work.
>
> Regards,
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


Mime
View raw message