question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Original select has 'required' attribute, doesn't work fine

See original GitHub issue

Hello,

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:closed
  • Created 11 years ago
  • Reactions:7
  • Comments:60 (12 by maintainers)

github_iconTop GitHub Comments

9reactions
stale[bot]commented, Mar 13, 2019

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.

5reactions
epinedacommented, Mar 23, 2017

Finally I could solve it adding the following css:

.form-control.select2-hidden-accessible {
    top: 30px;
}

( I’m using select2 v4.0.3 with select2-bootstrap-theme v0.1.0-beta.9 )

😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found