You should have it the way it was. parseInt tries to convert what's left
after stripping all of the ($), (.), and (,), into an integer. If it fails,
it will return NaN (Not a Number).

On 4/10/07, Rick Faircloth <[EMAIL PROTECTED]> wrote:


Well, it looks like I'm making progress...

I needed to change

if ( isNaN ( parseInt ( value.replace ( /[\$\,\.]/, "" ))))

to

if ( isNaN ( value.replace ( /[\$\,\.]/, "" )))

because I don't want to parse what's left.  If there's anything
besides digits, dollar signs, commas, and periods in the input,
I want an error to be thrown.

However, the problem I have now is the variations on the input
that should pass validation...

Here are some examples:

$255900 passes as a valid entry.
$255,900        does not pass and I want it to.
$255,900.       does not pass and I want it to.
$255,900.00     does not pass and I want it to.

But why?

The statement if ( isNaN ( value.replace (/[\$\,\.]/, "" )))
is stating that "if all dollar signs, commas, and periods are taken out
of the input entry, and the input is not a number"... right?

Rick



-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jörn Zaefferer
Sent: Tuesday, April 10, 2007 5:41 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Trying to figure out how to use this custom
validation...


Dan G. Switzer, II schrieb:
> Rick,
>
>
>> Here's the addMethod line:
>>
>>      $.validator.addMethod("superCoolValidator", superCoolValidator,
>> "Your input is not super cool!");
>>
>>      rules: {
>>
>>          //Principal: {required: true,
>>                       //digits: true},
>>          Interest: {required: true,
>>                      number: true},
>>          Years: {required: true,
>>                   number: true}
>>              },
>>
>
> I haven't messed with the custom validators in Jörn's code, but looking
> through the code, you'll need to assign a rule for the validator:
>
>       rules: {
>
>           Principal: {required: true,
>                        superCoolValidator: true,
>                        digits: true},
>           Interest: {required: true,
>                       number: true},
>           Years: {required: true,
>                    number: true}
>               },
>
Good job Dan, didn't notice that.

Rick: When you specify rules via plugin options, metadata is ignored. I
thought I documented that somewhere... Gonna fix that.

--
Jörn Zaefferer

http://bassistance.de






--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com

Reply via email to