Friday, January 2, 2009

[jQuery] Re: Will this code validate a number?

Nevermind... I figured out what was wrong.

I needed another / after the bracket to terminate the regex.

> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:jquery-en@googlegroups.com] On Behalf Of Rick Faircloth
> Sent: Friday, January 02, 2009 10:28 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Will this code validate a number?
>
>
> I'm running this code to validate that an entry
> into any field with a class of "number"
> is a number after all $,. are disregarded.
>
> I'm not getting any response on my page on blur
> for the field.
>
> Is there something wrong with this code?
>
> Thanks,
>
> Rick
>
> $(':input.number').each(function() {
> $(this).blur(function() {
> if ( isNaN (this.value.replace ( /[\$\,\./,""])))
> { $('#' + this.id + '_number_error').fadeIn(500);
> $('#submit').attr('disabled', 'disabled'); }
> else
> { $('#' + this.id + '_number_error').fadeOut(500);
> $('#submit').removeAttr('disabled'); };

No comments: