Comments (8)
Here's a CSS/HTML5 only solution:
<style>
select {
display: block !important;
margin: 0;
border: 0;
padding: 0;
height: 1px;
opacity: 0;
position: relative;
/* Top should be the same as the height of your */
/* unfocused, nice select replacement element! */
top: 30px;
}
</style>
<select name="my-field" required tabindex="-1">
</select>
from jquery-nice-select.
With Javascript:
var value = document.getElementById('id_of_select').value;
if(value == ""){
document.getElementById('id_of_result_div').innerHTML = "The select is required"
}else{
//your code...
}
from jquery-nice-select.
What do you mean? Please expand.
from jquery-nice-select.
in html 5 there is "required" Attribute
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-required
from jquery-nice-select.
And what do you want the plugin to do?
from jquery-nice-select.
just to support the attribute
from jquery-nice-select.
Here's a CSS/HTML5 only solution:
<style> select { display: block !important; margin: 0; border: 0; padding: 0; height: 1px; opacity: 0; position: relative; /* Top should be the same as the height of your */ /* unfocused, nice select replacement element! */ top: 30px; } </style> <select name="my-field" required tabindex="-1"> </select>
Unexpected solution. Great work.
from jquery-nice-select.
Here's a CSS/HTML5 only solution:
<style> select { display: block !important; margin: 0; border: 0; padding: 0; height: 1px; opacity: 0; position: relative; /* Top should be the same as the height of your */ /* unfocused, nice select replacement element! */ top: 30px; } </style> <select name="my-field" required tabindex="-1"> </select>
Lovely, but there's an issue with this. When the user does not select a value in the list for the first time, it will who the HTML validation error. However, when the user corrects the value in the list, it continues showing the validation error and does not clear it off (seems like a change event needs to be propagated to the select element for this to work, I think)
from jquery-nice-select.
Related Issues (20)
- Not working in bootstrap modal HOT 1
- update not working append with append HOT 1
- tabindex is not working
- Using / for division outside of calc() is deprecated
- invalid form control with name='namefield' is not focusable HOT 3
- 508 Compliance?
- RTL support
- 'update' not rendering the elements HOT 5
- option.append() doesn't work HOT 2
- Bootstrap 4 validation HOT 1
- Nuxt.js : niceSelect is not a function HOT 1
- Didnt work with HTML onchange="" property HOT 1
- Required auto-suggestion
- NiceSelect Inside Bootstrap Modal
- Having class on options HOT 1
- Type of license? HOT 1
- Event Handler for Autocomplete and Click Off
- Can not select a value when the select is inside a label HOT 2
- Nice select dropdown not working with "e.stopPropagation();" HOT 1
- Fail to update options when they are not strings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-nice-select.