Is there a way of not letting users change a select input?.
I have a form with an already selected option, and I want to aware users that they are doing that and I was trying to do this
I have a select with id=users,
$("#users").change(function(){
confirm("You are going to change the default value. Are you sure?");
});
One of the problems I have is that it only happens if I click on an option, it's not happening as soon as I click on the select input.
Another thing is that it shows 2 times, is there a way of handle this?
And the last question, how can I make that after click on "cancel" button of the confirm window, it won't display the list of options and if I click on "accept" it should display the options.
I guess what I'm trying to do is a intermediate event between not doing anything and after click event on that select.
Hope someone can help me.
Thanks in advance
Javier Q
It's basically what Tetsujin no Oni said, but there's no reason you can't do it with a select. Just intercept a mousedown instead of a click (so it is instantaneous) and prevent the default behavior if necessary:
http://jsfiddle.net/zKHaj/5/
Also, you may want to add a boolean variable like "hasAccepted" so that you they only have to do the confirmation once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With