Re: Widget javascript validation problem

2006-07-05 Thread Andrew Madu
Gary,if(!/^[0-9]{16}$/.test(account_no.value)) { //This is invalid }
will match an account number with no spaces.many thanks for that heads up. All is working a treat now.regardsAndrew


RE: Widget javascript validation problem

2006-07-05 Thread Stewart, Gary

-Original Message-
From: Andrew Madu [mailto:[EMAIL PROTECTED]
Sent: 05 July 2006 13:13
To: users@cocoon.apache.org
Subject: Re: Widget javascript validation problem

> The other problem I am having is with the widget datatype definition for 
> account_no:
> 
> fd:datatype base="integer" 

I've never used that datatype. However I tend to use regex to do any validation 
checking something like:

if(!/^[0-9]{16}$/.test(account_no.value)) { //This is invalid } 

will match an account number with no spaces.

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Widget javascript validation problem

2006-07-05 Thread Andrew Madu
Gary,At a glance it looks like *account_no.setValidationError* is wrong as you declared the variable as *accountNumberLength*. This is why I like strict type checking.
that now works fine now. I remember having done the same mistake a while ago, and was trying to chek against the actual widget id I specified in fd:widgets instead of against the _javascript_ values holding the 
lookupWidget objects!!!The other problem I am having is with the widget datatype definition for account_no:fd:datatype base="integer"Does this actually do what it should do? I enter an alpanumeric value of '12der456' and when you submit the form it accepts the value as valid!!!, when it quite clearly isn't. What is the issue here? If I enter 'der12456' then the value is rejected as invalid. I entered the following code in the _javascript_ validation but this as well had no effect:
            if (isNaN(parseInt(account_no.value))) {                account_no.setValidationError(new Packages.org.apache.cocoon.forms.validation.ValidationError("The value entered is not a numeric number. Please re-enter the number.", false));
                success = false;            }regardsAndrew 


RE: Widget javascript validation problem

2006-07-05 Thread Stewart, Gary

-Original Message-
From: Andrew Madu [mailto:[EMAIL PROTECTED]
Sent: 05 July 2006 12:31
To: users@cocoon.apache.org
Subject: Widget javascript validation problem


> 
>
>var success = true;
>var creditCardType = widget.lookupWidget("credit");
>var accountNumberLength = widget.lookupWidget("account_no"); 
>
>try {
>//Determine the credit card type and then check that the length 
>//of the credit card number is correct for the credit card type.
>
>if ( creditCardType.value == "visa" && 
> accountNumberLength.value.length != 16) {
>account_no.setValidationError(new 
> Packages.org.apache.cocoon.forms.validation.ValidationError("Visa card 
> numbers are 16 chracters in length. Please re-enter the number.", false)); 
>success = false;
>}
>
>} catch (e) {
>
>}
>
>return success;
>
> 
 
I had lots of problems when I first started with validation. Thankfully you 
don't seem to be doing any of those. At a glance it looks like 
*account_no.setValidationError* is wrong as you declared the variable as 
*accountNumberLength*. This is why I like strict type checking.

Hope that helps,

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]