Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Select with multiple attribute initially has error validation on page load #393

Closed
ArcadeRenegade opened this issue Aug 10, 2016 · 5 comments
Labels

Comments

@ArcadeRenegade
Copy link

ArcadeRenegade commented Aug 10, 2016

Steps to reproduce:

  • Create a form with the [data-toggle="validator"] attribute.
  • Add to the form a select element as a .form-control with the [multiple] and [required] attributes.
  • Load web page
  • Select element has error initially on load

image

@pgs-pliulia
Copy link

Hi, i have the same errors and i find why. As of jQuery 3.0, if no options are selected, it returns an empty array; prior to jQuery 3.0, it returns null. So, if you have < jQuery 3.0 the validation will fail. I will try to fix that in the weekend

@desfero
Copy link
Contributor

desfero commented Nov 4, 2016

JSBin for this issue: JSBin: http://jsbin.com/foyogogogo/edit?html,output
Can any one add Bug label?

@1000hz 1000hz added the bug label Nov 4, 2016
@1000hz
Copy link
Owner

1000hz commented Nov 4, 2016

Seems like maybe it wasn't the best idea to automatically validate fields on plugin init. This is also causing problems for people in #401.

I think I'll revert the changes from #350 and leave it up to people who want that behavior to trigger validation themselves.

@desfero
Copy link
Contributor

desfero commented Nov 5, 2016

If we revert changes, it will not help. Current issue is because of logic which check if values is empty is incorrect due to changes in jQuery >= 3.0 where .val() function return empty array for with multiple attribute prior to jQuery 3.0 it returns null,

@desfero
Copy link
Contributor

desfero commented Nov 9, 2016

@1000hz i submit a pull request to fix this issue

1000hz added a commit that referenced this issue Dec 5, 2016
#393 Select with multiple and required attributes .has-error in pristine mode
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants