Calling reset() in a form does not move the label back over


Topic: Calling reset() in a form does not move the label back over input on form items

Everton Gabriel pro asked 10 years ago

When a input is empty clicking it makes the label move up, you can add text and click outside then the label keeps in the above position (good behavior). Then if I click again and make the field empty it and click outside the label will move over the label again (good behavior). Now if I fill the input and call form.reset() the field will be empty but the label will not go back over the label. Is there any way to solve this? How do I make the labels realize the inputs are empty and make then move back over the labels? The idea is to submit a form via ajax and reset it to empty state so a new form can be inputted.

Everton Gabriel pro answered 10 years ago

This is the workaround so far:

  $(form).find(':input').each(function(ix,el)
  {
    el.focus();
  });
  document.activeElement.blur();

Bartłomiej Malanowski staff pro premium answered 10 years ago

Try to remove ".active" class from label when you want to reset form
Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags