Hi, all...

I'm writing some validation code and have an input
for dollar amounts and would like for users to be able to
enter digits or $ or , or .  all of which are commonly
used in US dollar values.

The code I've written should verify that after any $ or , or .
are removed from a user's entry, there is only digits remaining.

However, when I enter either $ or , or .  into the string,
the string is rejected as valid.

$1200 doesn't even pass.

Is there something wrong with my code or logic?

Thanks for any feedback,

Rick

Here's the code:

$(':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(250);
                   $('#submit').removeAttr('disabled'); };
       });
}); 

Reply via email to