hey all,
my question is, can i give some kind of title to the select tag so it will appear in the select but when opening the drop down menu it will not be one of the options?
I’m not aware of anything that enables you to have dummy text in the select box that isn’t one of the options. What you would need to do is to validate the input so that when the surfer tries to submit the form, if they haven’t changed it from “Please select…” to one of the other options, the form is rejected and they are asked to complete that entry.
It’s not possible using HTML. The question is whether you want to do it. Most users know how select form elements work. Rather than having a dummy value, why not use the value most commonly selected as the default, saving the majority of the users a little time?
Probably the nearest is to use the attributes: selected=“selected” and disabled=“disabled” of course you would have to be happy with a disabled item appearing by default.
thanks for the responses, seems like there’s no proper solution for this so ill just stick to how the way it is now, and just put some check if the value of the option tags is different than “select” , or like C. Ankerstjerne suggested, i’ll just put the most common selection first
Like I said above if it has the attributes ‘disabled’ and ‘selected’; it would be both the “default” option and won’t be able to pass on data. Thus the normal user could NOT post or select that value in the first place. Neither would it allow focus and doesn’t require the user to have JavaScript enabled to function correctly.
Not “ideal” but covers all the major points in the original question. Obviously you’ll still need server-side validation at a bare minimum anyway.