I have created this on my Shopify website:
<select class="className" name="valueSelect" id="testId" required>
<option value="none" selected disabled hidden></option>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
The problem is that the doesn’t work if the gender value isn’t selected – leaving it empty still let’s me through. Is there a way to control this?
3
Answers
You can remove empty option and set default value, for example A.
Assuming that the validation or submission of select happens when the user clicks a button and this invokes a function.
The value can be checked and then the function call can be made on the button click
You can use javascript like this.(check running snippet)
Just give id="btn" to your submit button and onclick="func()" and paste this javascript.