Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How do I reset the position of the floating label of a standard Input when emptying it with JavaScript?

ikan_nak priority asked 1 month ago


Expected behavior

I have an input with a floating label (see snippet). I want to set the value back to null with Javascript. If i do so using document.getElementById().value, it doesn't reset the label position back to inside the component. I thought I could fix this by using the private Autocomplete._updateLabelPosition(); function that Kamila mentioned a week or so ago, but apparently a standard Input doesn't have that function (as can be seen by clicking the second button).

How do I reset this label position for an Input?

Resources (screenshots, code snippets etc.)

https://mdbootstrap.com/snippets/standard/ikan_nak/6307580#js-tab-view


ikan_nak priority answered 1 month ago


While debugging the Javascript code, I found the "forceInactive" function on the Input element that does what I'm looking for.



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 7.2.0
  • Device: Desktop computer
  • Browser: Edge
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: Yes