[jQuery] How can I write this function without hard-coding the input and error names?
Here's the code that I'd like to make flexible to handle
all the input id's and error message id's. How could I write it?
Thanks,
Rick
$('input#street_number').blur(function() {
if (this.value.length == 0)
{ $('#street-number-error').fadeIn(500);
$('#submit').attr('disabled', 'disabled') }
else
{ $('#street-number-error').fadeOut(500);
$('#submit').attr('disabled', '') };
});
$('input#street_name').blur(function() {
if (this.value.length == 0)
{ $('#street-name-error').fadeIn(500) }
else
{ $('#street-name-error').fadeOut(500) };
});
$('input#city').blur(function() {
if (this.value.length == 0)
{ $('#city-error').fadeIn(500) }
else
{ $('#city-error').fadeOut(500) };
});