Reputation: 969
I have many textboxes in a form. When its respective value fails validation a class 'has-error' is applied, which adds a red border to the textbox.
I would like to undo this class if that textbox get focus.
Something like
$(document).on('focus',find(':input'),function(){
$(this).removeClass('has-error');
});
How is this done?
Upvotes: 0
Views: 307
Reputation: 104795
Just do:
$(document).on("focus", "input:text.has-error", function() {
Upvotes: 1
Reputation: 57105
You don't need find(':input')
just use ':input.has-error'
$(document).on('focus', ':input.has-error' ,function(){
$(this).removeClass('has-error');
});
And also make sure your code in DOM Ready
Upvotes: 3