Answer the question
In order to leave comments, you need to log in
How to do validation for select?
By default, select required, if the user has not selected anything from the list, then the form will not work. I need that if the user has not selected anything from the list, then get an error message next to the select that you need to select a value
<select name="" class="form-control" required>
<option selected disabled value="">--Выбрать--</option>
<option value="1">value 1</option>
<option value="2">value 2</option>
<option value="3">value 3</option>
<option value="4">value 4</option>
<option value="5">value 5</option>
</select>
Answer the question
In order to leave comments, you need to log in
А в чём собственно заключается проблема? Мне кажется, атрибуты selected и disabled не совместимы друг с другом. Их вообще стоит убрать оба (по-умолчанию выбирается первый option), браузер должен ругаться на пустой value у option.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question