-
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
Could you tell me the way to validate form when the input is clean. #10
Comments
Hello @NguyenVanVuong You can use Here's the example <form name="Form">
<input type="text" name="number" ng-model="form.number" validator="number"/>
<button ng-click="form.submit(Form)"></button>
</form>
<script>
$scope.form = {
submit: function (form) {
$validationProvider.validate(form)
.success(successCallback)
.error(errorCallback);
}
};
// ...
</script> |
@huei90 https://github.com/huei90/angular-validation/blob/master/dist/angular-validation.js#L320
But when initial with [required] validator, althought the field is empty but $validationProvider.getExpression(validation).test(value) still return true; So i have to edit it be to:
Plz check regex of [required] validator |
You are right , but That's means Here's the reference And I suggested you use |
@huei90 |
Thanks for pointing out this problem. Here's my solution http://plnkr.co/edit/LMQXsQ?p=preview You have to get the $timeout(function () {
$validationProvider.validate($scope.Form);
}); And we should use $timeout to make sure |
Thanks for your issue and I have added Thanks again! _Perhaps I have to add a provider to easy this_ |
@huei90 Thank for support 👯 |
@NguyenVanVuong Issue me if you have other suggestion 😄 |
Could you tell me the way to validate form when the input is clean.
I have a model $scope.form and it is empty object.
Now, I want to auto show validate message at initial screen.
Example: Althought user has not interacted with the form, but it show the message error
The text was updated successfully, but these errors were encountered: