Forum
How to force selecting from a dropdown list?
I have a dropdown list that's working on a form, but visitors are letting it default to the first value. I want them to select a value and for the default (first entry) to be an invalid selection. This is the current code ...
<perch:label for="subject">Subject (select from the list)</perch:label>
<perch:input type="select" id="subject" required="true" label="Subject" options="Starting a new group, Fundraising, Practical support, Local networks, Running an organisation, Training, Room booking, Volunteering, Other" />
<perch:error for="subject" type="required">Please select a subject</perch:error>
I'd like the dropdown list to start with 'Choose from this list...'. Therefore the perch:input line would be as below.
<perch:input type="select" id="subject" required="true" label="Subject" options="Choose from this list..., Starting a new group, Fundraising, Practical support, Local networks, Running an organisation, Training, Room booking, Volunteering, Other" />
But I want that first option to be an invalid choice and the form validation to fail unless they choose one of the other values. If you've got a way of doing this on your forms, would you enlighten me please?
Thanks, Graham
Hi Graham, try adding:
allowempty="false" required="true" placeholder="Choose from this list..."
instead of adding it as an actual option.Perfect. Thanks. Solved the problem perfectly (and now logged away for the future).