Topic: Input label when setting the empty value

esec priority asked 2 years ago


Expected behavior Input will automatically change state to inactive and pull the label down when an empty string is set via jQuery .val() method (for example $("#myInput").val("");) OR mention a mdb.Input.forceActive() and mdb.Input.forceInactive() in docs here.

Actual behavior Neither of these things are not done and that can lead to confusion, because when I want to clear the input programmatically and will look just in the provided docs, this task is impossible to be done. When cleared via the jQuery .val() as mentioned, the input value will clear, but the label will stay up as long as user won't focus and blur on that input. You have to use mdb.Input.forceInactive() method to pull the label down (.update() is not working on this). I had to look directly into the mdb JS code to find this method.

Resources (screenshots, code snippets etc.) Working snippet in case anyone will have the same problem as me:

$('#myInput').val('');
myInput_instance.forceInactive(); // where myInput_instance is an instance of mdb.Input()

Michał Duszak staff answered 2 years ago


Hello,

thank you for your feedback. You're right, in order for label to update the blur event has to occur. We will discuss this case with our frontend team so that we can provide the best solution.

Best regards,

Michal



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.4.0
  • Device: All
  • Browser: All
  • OS: All
  • Provided sample code: Yes
  • Provided link: Yes