-
Notifications
You must be signed in to change notification settings - Fork 176
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-reset and has-error input #135
Comments
Check your code again. You add and remove class on the And tell me the result. |
Just added console.log() to my code snippet: angular.extend($validationProvider, {
validCallback: function (element) {
console.log("validCallback");
element.parent().removeClass('has-error');
},
invalidCallback: function (element) {
console.log("invalidCallback");
element.parent().addClass('has-error');
}
}); and then I clicked button with validation-reset on it and I've got two invalidCallback events |
Pay attention that these inputs have validators. It seems like validation-reset fires invalidCallback |
Yes you are right. The reset will manually remove the value and remove the invalid element, and might trigger the invalidcallback function. Reset must be clean. This should be improve! Thanks @alexgoroshko |
But if you make clear reset validation (without events) it won't solve the problem. It means if there is a validation error so "angular-validation" adds has-error class to parent div (because I need bootstrap red border on invalid input). Then just try to reset validation and it will remove just validation error message and has-error class will be still on div. Have you any ideas how to correctly reset validation, just return to neutral state like it was before validating? |
Maybe add some reset-validation event where we will be able to set initial state like it's supposed to be before validation. |
Have you tried this when using angular-validation in Bootstrap? |
Yes, I have. I was talking about reset-validation, that if you want to reset form validation where already exist some validation errors it won't fire validCallback and |
Yes, i get your point. We need a better and real |
@Nazanin1369 Any opinion on this issue? |
Even in your demo http://huei90.github.io/angular-validation/ when you just reload the page, input is clear, without ng-invalid class. Then type just something wrong to get validation error. As you see for now input has a ng-invalid class. Then just reset the form. There is nothing happens with input, it's still have all validation error classes |
Yes, therefore
|
I will look into it
|
Hi @alexgoroshko The problem is fixed now. Please try again. Open the issue if needed. |
I extended validation provider like that:
And then I just put some invalid data to input to get validation error
As you see angular validation properly added has-error class to the parent div and added a validation error message.
But when I click reset validation, has-error class appears on the first input and is still on the second one, but error message disappear
What am I doing wrong?
The text was updated successfully, but these errors were encountered: