Skip to content

Commit b4d750a

Browse files
committed
ShowHeloOnFocus plugin to use named helper
Updated span to use .jquery_form_help_{name} format and leave helper spans in dom after fade out. No real need to recreate the dom element if the user brings that field back into focus.
1 parent f4fc4f5 commit b4d750a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

jquery.formvalidator.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,24 @@
4444
if(help) {
4545
$(this)
4646
.focus(function() {
47+
var $name = $(this).attr('name');
4748
var $element = $(this);
48-
if($element.parent().find('.jquery_form_help').length == 0) {
49+
if($element.parent().find('.jquery_form_help_'+$name).length == 0) {
4950
$element.after(
5051
$('<span />')
51-
.addClass('jquery_form_help')
52+
.addClass('jquery_form_help_'+$name)
5253
.text(help)
5354
.hide()
5455
.fadeIn()
5556
);
57+
}else{
58+
$element.parent().find('.jquery_form_help_'+$name).fadeIn();
5659
}
5760
})
5861
.blur(function() {
59-
$(this).parent().find('.jquery_form_help')
60-
.fadeOut('slow', function() {
61-
$(this).remove();
62-
});
62+
var $name = $(this).attr('name');
63+
$(this).parent().find('.jquery_form_help_'+$name)
64+
.fadeOut('slow');
6365
});
6466
}
6567
});

0 commit comments

Comments
 (0)