-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Error ng-invalid-date - (Solutions in badInputChecker() ) #12853
Comments
I think this is a duplicate of #12207. If that is indeed the case, you can take a look at #12207 (comment) for temporary work-around (until this is properly resolved). |
It is not the same problem. Have this plnker. It is actually a fork from the one you linked. 1 - Choose a Full Date. It is working as expected, now the problem: 1 - Choose a Full Date. It is not working as expected, it should return to $valid. |
Actually, it is the same. The problem does not lie in For a more detailed explanation and a temporary work-around, read the discussion in #12207. Closing as duplicate of #12207. |
Hi @gkalpak |
@kimx, seems like a valid issue. Can you please open a new issue ? |
Interesting facts:
|
So…Do you have any suggestions? |
@kimx: I have a few. For whom? For users: As a workaround, you can trigger an For Chrome: Always trigger an input event, when then user clicks "X". For us: Not sure. Listening for For you: Open a new issue, so we can track this. (I know I could do it myself, but it's your finding - I don't want to steal your thunder 😛 ) /cc @jbedard |
I have a input type = "Date" not required in my form linked to a
ng - model = "date" , when I add a value to the component
and then use the delete key to erase the value , the angular adds
the ng -invalid class component and adds to the value undefined , making my form
invalid.
The solution would be changing the function which adds badInputChecker undefined
for the component , that function should be changed to set null instead of undefined.
Thus, the component will only be invalid if required .
function badInputChecker(scope, element, attr, ctrl) {
var node = element[0];
var nativeValidation = ctrl.$$hasNativeValidators = isObject(node.validity);
if (nativeValidation) {
ctrl.$parsers.push(function(value) {
var validity = element.prop(VALIDITY_STATE_PROPERTY) || {};
// Detect bug in FF35 for inputemail:
// - also sets validity.badInput (should only be validity.typeMismatch).
// - see http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#e-mail-state-(type=email)
// - can ignore this case as we can still read out the erroneous email...
//return validity.badInput && !validity.typeMismatch ? undefined: value; old
return validity.badInput && !validity.typeMismatch ? null : value; //new
});
}
}
Best regards
The text was updated successfully, but these errors were encountered: