Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate select option for a Materialize dropdown?

I've got a basic select box using materializecss.

<select id="type" name="type" required="required" class="validate">
    <option value="" disabled="true" selected="selected">Choose your option</option>
    <option value="general">General</option>
    <option value="tech">Tech</option>
    <option value="person">Personnel</option>
    <option value="resource">Resourcing</option>
</select>
<label data-error="Select an option">Type of Question</label>

I want the user to select an option before being able to submit the form.

How can I get it to display the data-error for the label if user doesn't select an option?

like image 478
Aeseir Avatar asked Dec 13 '15 07:12

Aeseir


1 Answers

$("select[required]").css({display: "block", height: 0, padding: 0, width: 0, position: 'absolute'});
like image 81
Imran Saleem Avatar answered Oct 12 '22 21:10

Imran Saleem