html5-pre-selected-disable-default.webp

HTML drop-down placeholder

Do you ever wanted to have an HTML drop-down with default selected value (placeholder) that the user cannot re-select once they selected any valid value options? It can be done easily by adding selected and disabled attributes on the option element. Code Snippet <select> <option value="" selected="selected" disabled="disabled">-- SELECT --</option> <option value="ACTIVE">ACTIVE</option> <option value="INACTIVE">INACTIVE</option> </select> Try it! -- SELECT -- ACTIVE INACTIVE

April 15, 2020 ยท John Pili