Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

input [checkbox] ng-true-value="1" required - never validates #4681

Closed
penfold opened this issue Oct 28, 2013 · 4 comments
Closed

input [checkbox] ng-true-value="1" required - never validates #4681

penfold opened this issue Oct 28, 2013 · 4 comments

Comments

@penfold
Copy link

penfold commented Oct 28, 2013

Following changes from 1.2rc2 to 1.2rc3, the behaviour of the checkbox has changed.

An element:

<input type="checkbox" ng-model="terms" ng-true-value="1" required>Check me</input>

Is not valid when it is checked. The function on the checkboxInputType controller function:

  ctrl.$isEmpty = function(value) {
    return value !== trueValue;
  };

Is getting passed value=true when the checkbox is checked. Therefore, the required validation is failing. (true !== "1" is true).

Browser: Chrome & FireFox (latest builds)

@tydanielson
Copy link

This is still a problem in 1.2.5

@caitp
Copy link
Contributor

caitp commented Dec 19, 2013

I'm fairly sure this would be closed by #5346 --- care to try it and see? The tests validate it against objects and stuff, so I'm not sure why it wouldn't work in that case

The funny thing is, it's not clear how you make a checkbox "required", there are different semantics for that --- you could say, semantically it must not be indeterminate (must be explicitly checked or unchecked), so it seems a bit off to default to "=== true". But hey, I guess it's probably not too hard to write a custom directive for that one.

@btford
Copy link
Contributor

btford commented Feb 5, 2014

Closing due to inactivity.

Also I agree with @caitp – I'm not sure such a thing makes sense in core.

@ByScripts
Copy link

I really need to use ng-true-value with ng-required. How can I do?

(Tested with Angular 1.3 with success... but I can't use 1.3 because IE8 support is a project requirement)

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

No branches or pull requests

5 participants