You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Stewart, Gary" <Ga...@luht.scot.nhs.uk> on 2006/02/14 13:01:04 UTC

CForms Javascript Validation

Hello,

I'm using Cocoon 2.1.8 and attempting to develop a few CForms. I've been working on validating the forms and for some widgets I'm attempting to use Javascript but it doesn't seem to be working. I looked at the sample files and could only find Javascript validation for the whole form. Is it possible to do something like:

<fd:field id="foo" >
	<fd:label>Foo:</fd:label>
	<fd:datatype base="string"/>
    	<fd:validation> 
	   	<javascript>
		   return false;
        	<javascript>
        </fd:validation>
        <fd:on-value-changed>
	    <javascript>
	      this.validate();
	    </javascript>
        </fd:on-value-changed>
</fd:field>

obviously the validation would normally be more complex but I figured this is the easiest to get to work.

Also does it matter if you use the namespace <fd:javascript /> or should javascript always be in the xmlns="" namespace?

Thanks (and sorry to keep throwing so many CForms questions),

Gary

*****************************************************************
The information contained in this message may be confidential or 
legally privileged and is intended for the addressee only, If you 
have received this message in error or there are any problems, 
please notify the originator immediately. The unauthorised use, 
disclosure, copying or alteration of this message is 
strictly forbidden.
*****************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: CForms Javascript Validation

Posted by Robin Wyles <ro...@robinwyles.com>.
Like this...

<fd:field id="foo" >
	<fd:label>Foo:</fd:label>
	<fd:datatype base="string"/>
	<fd:validation>
		<fd:javascript>
	   		return yourValidationMethod(widget);
		<fd:javascript>
	</fd:validation>
</fd:field>

The JS you use for validation must return true/false depending on the  
validation success. There are samples of custom validation with JS in  
the cocoon distribution...

Robin


On 14 Feb 2006, at 13:01, Stewart, Gary wrote:

> Hello,
>
> I'm using Cocoon 2.1.8 and attempting to develop a few CForms. I've  
> been working on validating the forms and for some widgets I'm  
> attempting to use Javascript but it doesn't seem to be working. I  
> looked at the sample files and could only find Javascript  
> validation for the whole form. Is it possible to do something like:
>
> <fd:field id="foo" >
> 	<fd:label>Foo:</fd:label>
> 	<fd:datatype base="string"/>
>     	<fd:validation>
> 	   	<javascript>
> 		   return false;
>         	<javascript>
>         </fd:validation>
>         <fd:on-value-changed>
> 	    <javascript>
> 	      this.validate();
> 	    </javascript>
>         </fd:on-value-changed>
> </fd:field>
>
> obviously the validation would normally be more complex but I  
> figured this is the easiest to get to work.
>
> Also does it matter if you use the namespace <fd:javascript /> or  
> should javascript always be in the xmlns="" namespace?
>
> Thanks (and sorry to keep throwing so many CForms questions),
>
> Gary
>
> *****************************************************************
> The information contained in this message may be confidential or
> legally privileged and is intended for the addressee only, If you
> have received this message in error or there are any problems,
> please notify the originator immediately. The unauthorised use,
> disclosure, copying or alteration of this message is
> strictly forbidden.
> *****************************************************************
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: CForms Javascript Validation

Posted by Kris Schneider <ks...@gmail.com>.
On 2/14/06, Stewart, Gary <Ga...@luht.scot.nhs.uk> wrote:
> Hello,
>
> I'm using Cocoon 2.1.8 and attempting to develop a few CForms. I've been working on validating the forms and for some widgets I'm attempting to use Javascript but it doesn't seem to be working. I looked at the sample files and could only find Javascript validation for the whole form. Is it possible to do something like:
>
> <fd:field id="foo" >
>         <fd:label>Foo:</fd:label>
>         <fd:datatype base="string"/>
>         <fd:validation>
>                 <javascript>
>                    return false;
>                 <javascript>
>         </fd:validation>
>         <fd:on-value-changed>
>             <javascript>
>               this.validate();
>             </javascript>
>         </fd:on-value-changed>
> </fd:field>
>
> obviously the validation would normally be more complex but I figured this is the easiest to get to work.
>
> Also does it matter if you use the namespace <fd:javascript /> or should javascript always be in the xmlns="" namespace?

Use <fd:javascript>...</fd:javascript>

> Thanks (and sorry to keep throwing so many CForms questions),
>
> Gary

--
Kris Schneider <ma...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org