Friday, January 2, 2009

[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:

Post a Comment