Skip to content

Commit

Permalink
Merge pull request Dogfalo#454 from afifsohaili/bugfix/prepopulated-f…
Browse files Browse the repository at this point in the history
…orm-elements

Add .active to label elements if input has been prepopulated
  • Loading branch information
Dogfalo committed Jan 13, 2015
2 parents 25d38e8 + 7154f7a commit aae3378
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
}
});

// Add active if input element has been pre-populated on document ready
$(document).ready(function() {
$(input_selector).each(function(index, element) {
if($(element).val().length > 0) {
$(this).siblings('label, i').addClass('active');
}
});
});

// Add active when element has focus
$(document).on('focus', input_selector, function () {
$(this).siblings('label, i').addClass('active');
Expand Down

0 comments on commit aae3378

Please sign in to comment.