Git Product home page Git Product logo

Comments (8)

mlkdev avatar mlkdev commented on September 13, 2024 10

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.

marcostor13 avatar marcostor13 commented on September 13, 2024 1

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.

hernansartorio avatar hernansartorio commented on September 13, 2024

What do you mean? Please expand.

from jquery-nice-select.

Antonimo avatar Antonimo commented on September 13, 2024

in html 5 there is "required" Attribute
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-required

from jquery-nice-select.

hernansartorio avatar hernansartorio commented on September 13, 2024

And what do you want the plugin to do?

from jquery-nice-select.

Antonimo avatar Antonimo commented on September 13, 2024

just to support the attribute

from jquery-nice-select.

mbparvezme avatar mbparvezme commented on September 13, 2024

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.

ameed-aabidi avatar ameed-aabidi commented on September 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.