I created a Plunker that displays a simple form with a required email field. The validation works when the user types in the email but is there a way to trigger the validation when clicking on the button. I don't want to disable the button based on the form validity.
Right now, you're binding ng-show to data that changes whenever the user types. Instead bind it to data that changes when the button is clicked. Here's my take on it:
$scope.update = function(user) {
$scope.isEmptyEmail = $scope.form.uEmail.$error.required;
$scope.isInvalidEmail = $scope.form.uEmail.$error.email;
};
And then bind your data to these new values.
<span ng-show="isEmptyEmail">Tell us your email.</span>
<span ng-show="isInvalidEmail">This is not a valid email.</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With