Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation crashes for mutiple select. #18

Closed
dkiestra opened this issue Apr 5, 2013 · 4 comments
Closed

Validation crashes for mutiple select. #18

dkiestra opened this issue Apr 5, 2013 · 4 comments

Comments

@dkiestra
Copy link

dkiestra commented Apr 5, 2013

Validation crashes when it is possible to make multiple selections using a 'select' element. I have to add the following code in the validate_required() function to make it work.

if ($("[name="" + attribute + ""]").attr('multiple') === 'multiple') {
return $("[name="" + attribute + ""] option:selected").size() > 0;
}

@joecwallace
Copy link
Owner

I'm unable to reproduce this. What jQuery and browser versions are you using?

@dkiestra
Copy link
Author

dkiestra commented Apr 9, 2013

Hi Joe,

I'm using Mozilla Firefox v20.0 and jQuery-1.9.1.
I did some more testing and I made a test file.
Please see multi-select.html file in attachment.
Validation fails when no selection is made.

Also, when one or more selections are made,
it does not show the alert message with the selected options.

However, when I add the following code to the validate_required()
function it works.

if ($("[name="" + attribute + ""]").attr('multiple') === 'multiple') {
return $("[name="" + attribute + ""] option:selected").size() > 0;
}

Thanks for the excellent support, Douwe.

On 2013-04-09 08:40, Joe Wallace wrote:

I'm unable to reproduce this. What jQuery and browser versions are you
using?


Reply to this email directly or view it on GitHub
#18 (comment).

@joecwallace
Copy link
Owner

Thanks for bringing this issue to my attention. I just pushed a fix. It's a little bit different than what you proposed, but you definitely set me down the path.

@dkiestra
Copy link
Author

Hi Joe,

I like your programming style. Elegant and compact.

There's one minor issue with your latest code.
When no selection is made I get a JavaScript error
due to value being null/undefined and the validation fails.

When I add the following code at the start of the validate_match()
function it works.

if (value === null) {
return false;
}

Thanks, Douwe.

On 2013-04-11 08:52, Joe Wallace wrote:

Thanks for bringing this issue to my attention. I just pushed a fix.
It's a little bit different than what you proposed, but you definitely
set me down the path.


Reply to this email directly or view it on GitHub
#18 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants