Topic: Pre-filling Input Fields with Javascript Leaves label blocking field content
mark.sauer pro asked 8 years ago
$("#fieldId").val(myValue);
This works, but the field label does not move out of the field content area and leaves the content blocked. Once you tab through the fields, the script then seems to know that there is content in the field and moves up. The desired behavior is to have the label move up when I populate the value with script. Can I force this perhaps with a JQuery event trigger? mark.sauer pro answered 8 years ago
function fixFieldState(inputField) {
$(inputField).trigger("focusin");
$(inputField).trigger("blur");
}
I can then call the following on any field after setting the value and the state of the field will be corrected. Not a great solution, but it does work.
fixFieldState($("#field_id"));
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No