Original select has 'required' attribute, doesn't work fine
See original GitHub issueHello,
I think this is the better plugin I’ve ever used 😉
My question is related to the ‘required’ attribute.
let me explain better I have a html page like this:
<form name="myForm" action="myAction" >
<select id="myId" name="myName" required="true" >
<option value="myvalue">An Element</option>
</select>
<button type="submit" >Go</button>
</form>
<script>
$("#myId").select2({placeholder: "Select"});
</script>
When I click on the submit button of the form containing the select above, I see the internal browser’s message “Please select an element from the list”. That’s right, because I want browser shows the message.
The problem is that the message is not correctly shown, maybe caused by “display: none” of the original select when I do: $(“#myId”).select2()
Is there a way to avoid this annoyance?
thanks in advance and good job again 😉
Issue Analytics
- State:
- Created 11 years ago
- Reactions:7
- Comments:60 (12 by maintainers)
Top Results From Across the Web
javascript - <select> required not working - Stack Overflow
"The required attribute is a boolean attribute. When specified, the element is required." <select name="category" required ...
Read more >HTML <select> required Attribute not working in Visualforce?
In my code below I have two fields of type text and select, the validation runs on the text field if it remains...
Read more >6 Reasons - HTML5 Required Attribute Validation not Working
1. The Form Tag has “novalidate” Attribute · 2. Required Attribute Validation doesn't Work with Unclosed Input Tags · 3. The Button is...
Read more >HTML Required Not Working: 5 Issues That Cause It
The required attribute is there in the HTML select element. If it is not working for you, then try checking back the “first...
Read more >“Required” on select field doesn't work - WordPress.org
my issue is that I can't set this field as “required”. Also “disabled” attribute on first option doesn't work, but this seems me...
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
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Finally I could solve it adding the following css:
( I’m using select2 v4.0.3 with select2-bootstrap-theme v0.1.0-beta.9 )
😃