How do I Validate Input Type Select
See original GitHub issueSuppose I have a below select element:
<AvField type="select" id="SalaryType" name="SalaryType" helpMessage="" required > <option>Select Frequency of Salary</option> <option value="1">Monthly</option> <option value="2">Bi-Weekly</option> <option value="3">Weekly</option> <option value="4">Fortnightly</option> </AvField>
Is there a option to show error when selected option is ‘Select Frequency of Salary’?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Validate select box - javascript - Stack Overflow
select = document.getElementById('select'); // or in jQuery use: select = this; if (select.value) ...
Read more >Validate (Check) HTML Select DropDownList using JavaScript ...
Here Mudassar Ahmed Khan has explained how to validate (check) HTML Select DropDownList using JavaScript and jQuery. ; select id="ddlFruits"> ; select> ;...
Read more >HTML select required Attribute - W3Schools
The required attribute is a boolean attribute. When present, it specifies the user is required to select a value before submitting the form....
Read more >Form Validation - Tom Select
User input validation in Tom Select is built on standard validation protocols introduced by HTML5. As a user changes the items of a...
Read more >Validation · Bootstrap v5.0
HTML form validation is applied via CSS's two pseudo-classes, :invalid and :valid . It applies to <input> , <select> , and <textarea> elements....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If no
value
is set on an<option>
it will default to the text with in the<option>
(this is per the HTML spec and is handled by the browser). So, the first option ends up having the value ofSelect Frequency of Salary
, which is not empty so it passes therequired
validation. If you addvalue=""
to the option, it should work as you intended. Demo: https://stackblitz.com/edit/reactstrap-validation-v2-zk6fkc?file=Example.jsAlso, since the default value is will be
""
(after the change mentioned above), it will not show the error initially. If the user changes the value and then changes it back, it should show the error. Additional, it the user doesn’t change the value and tries to submit the form, it should show the error.Take a look at #19