0
<div class="form-group">
 <input type="text" name="Name"
    data-ng-model="panNumber" required> 
    <p data-ng-show="loginForm.Name.$error.required && (loginForm.Name.$touched || submitted)"
    class="error-block">Kindly enter your valid 10 digit PAN Number</p>
</div>

<button type="reset" data-ng-click="loginCtrl.reset()">RESET</button>

controller

this.reset = function(){
            $scope.loginForm.$setPristine();
            $scope.loginForm.$setValidity();
            $scope.loginForm.$setUntouched();
          };   

I have several fields in a loginForm, the problem is when user clicks on submit button without entering any data in any of the fields , all the error messages (required) are getting displayed. But when I reset button , the error messages are still present, they are not getting cleared.

I tried to debug a lot but not able to find the solution.I do not know what mistake I am doing.

Any help is appreciated !!!

Thanks

4
  • 1
    There is no required attribute added to input element. Add required attribute to input element and to the form tag, add "novalidate" attribute, to disable html5 validation Commented Sep 30, 2016 at 6:16
  • Hi , I have added it. Commented Sep 30, 2016 at 6:18
  • What is submitted? Commented Sep 30, 2016 at 6:20
  • I do not know exactly, this code is written by some one else, I am just trying to fix the bug. Commented Sep 30, 2016 at 6:35

1 Answer 1

0

I got the answer of this question by trying hard

just on click of reset button I need to call

$scope.submitted = false;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.