In this article, we will change the input border after filling the text on the input text field. The onchange event attribute works when the value of the element changes and selects the new value from the list.
Approach: Whenever the input value is changed with some value by the user, the onchange event attribute is triggered. After the event is fired, the value is checked if it is not null. If the user value exists, then the bottom border of the input control is changed to dotted red colour by using inline styling.
<element onchange = "script">
Example: In this example, we will change the border-bottom style when the user types some text in the field.
- Before filling the text:
- After filling the text:
- Google Chrome
- Internet Explorer