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

Required selects are validating when they haven't been selected #39

Closed
lukegalea opened this issue Mar 29, 2012 · 4 comments
Closed

Required selects are validating when they haven't been selected #39

lukegalea opened this issue Mar 29, 2012 · 4 comments

Comments

@lukegalea
Copy link

We're using both Model binding and backbone.validation.

For all other fields, when changing an empty field it appears to trigger validation only for that element.. But we have a bunch of s with placeholders (value=""). These all instantly trigger validation failures even though they have not been edited. To make matters worse, when submitting the form - even the the selects that have a value are triggering the "required" validation. Do not work at all?

@thedersen
Copy link
Owner

Sorry for the late reply. I use it with selects all the time, and have not encountered any issue. Do your selects have unique names? I suspect this has more to do with the modelbinding than the validation..

@thedersen
Copy link
Owner

Not able to re-produce..

@luaz
Copy link

luaz commented Jul 26, 2012

If the select box html code doesn't have a default empty value option, the 1st option value is selected by default. I believe the 1st value is "not actually selected", thus it will trigger a required validation. If you change the value by clicking on the select box, the required validation go away.

I suggest you do the either of the following:

  1. create a empty value option as default, thus forcing the user to click the select box to select a value
  2. or manually set the model's select attribute to a value before showing the form

@thedersen
Copy link
Owner

Ahh, ok

I use the same strategies as you suggest, and it works great.

Thanks!

laiso pushed a commit to laiso/backbone.validation that referenced this issue May 28, 2015
Fix for sortable table always removes items after sort stops
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

3 participants