Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

selectmenu does not support required validation #195

Closed
oleersoy opened this Issue · 16 comments

2 participants

@oleersoy

See:
http://bugs.jqueryui.com/ticket/7920

EDIT (by @fnagel), Ticket text:
The jquery ui selectmenu plugin does not support required validation. See the attached test case.
Speed form A contains a selectmenu widget.
Speed form B contains a vanilla select element.
Press "Validate Speed Form B" to see expected behavior.
Press "Validate Speed Form A" and the logger will log that that form is valid.

@fnagel
Owner

This branch of Selectmenu has no relation to the official jQuery UI releases maintained at bugs.jquery.com. Please see the Wiki for more Information. Please note there is a new, built from scratch version which is not released yet (#140). The new version will be included in official jQuery UI.

Ive changed the text of your issue. Please provide mentioned demos.

@oleersoy

I did create a pastebin (My first ever...):

http://jsbin.com/ufowub/14/edit#javascript,html

I can also email the archive with the test and resources. I'm assuming there's no way to attach here?

@fnagel
Owner
@oleersoy

Thanks - I'll try playing with the "Build from scratch" version to see if that makes a difference. The version I'm using in the test comes from:

https://github.com/fnagel/jquery-ui.git

Trying to get a little smarter at github and jsfiddle ATM.

@fnagel
Owner
@oleersoy

OK - I tested the new branch. It also has the same issue. I forked the fiddle that you setup. This is the URL:

http://jsfiddle.net/RYLvP/

I don't have a JSFiddle account, but I'm assuming that work will be cached anyways. I performed the test by modifying the default.html file in the "New" trunk.

@oleersoy

Which issues are most pressing ATM? I'll do my best to help.

@oleersoy

Here's what's happening. The JQuery Validator assumes that elements that have display set to none are valid.

@fnagel
Owner

You mean "The JQuery Validator assumes that elements that have display set to none are NOT valid." aka Validator ignores hidden form elements, correct?

Afaics you just need to use option.ignore, see: http://jsfiddle.net/RYLvP/1/

@oleersoy

I think we are saying the same thing. Hidden elements are effectively ignored...so they are essentially valid.

I'm assuming using "" for the ignore options tells the validator to validate all elements? In other words it's doing the inverse of what it was designed to do?

I love that there is a simple solution - Thanks!. I think a lot of future users will fall into the same hole I did though. Another potential issue is the positioning of validation messages. If the select element has the same dimensions and position as the span that proxies it, I suspect these would go away.

@fnagel
Owner

Nice to hear it worked for you.

If you dont specify specific options, the original select elements dimensions are used for the span. Positioning could be a problem, but these need to be addressed in the validation plugin. Perhaps this should be discussed with Jörn, the creator of the validation plugin.

@oleersoy

It looks good - Thanks again!

I need to play with this more, but I suspect there will be a positioning issue WRT the select element because the description of "display: none" says that it hides the element so it does not take up space in the page. So I would think that if the validation plugin tries to position a message relative to the element, the message could easily end up covered by or on top of the selectmenu span. (Perhaps visibility: hidden is a better option...?) The computed width in firebug stays in tact, but I don't know about other browsers. Users can always use a table to layout their validation messages, but it will be confusing at first if messages show up fine for jquery-ui buttons, but not for selectmenu instances.

Another design consideration might be what happens when someone needs to use the ignore option to actually ignore an element.

@fnagel
Owner

"it does not take up space in the page" is exactly what we wanted to achieve. Its a replacement.

In my opinion both, the positioning and the ignore option issue, needs to be discussed with the author of the validation plugin.

@oleersoy

Sure - Let me do a post on the forum and perhaps Jörn can put his perspective on it.

@oleersoy

I performed some more testing and the positioning of validation messages is different for jquery ui selectmenu instances and jquery ui buttons. When validating the content of buttons, messages appear by default to the right of the button. When using selectmenu the messages float to the top of the selectmenu instance.

@fnagel fnagel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.