AngularJS Confirm and Match Password Validation

AngularJS Confirm and Match Password Validation

In this Post We Will Explain About is AngularJS Confirm and Match Password Validation With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to confirm password validation in angularjs Example

In this post we will show you Best way to implement Angularjs password confirmation directive, hear for match password and confirm password in angularjs with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   Angular Multiple Carousel Image Slider




HTML Source code-sample (index.html)

<h2>Confirm Password Validation in AngularJS</h2>
<div ng-controller="repeatCtrl">  
   <form name="liveForm">  
  
      <div>  
         <label>Password</label>  
         <input type="password" name="livePass" ng-model="livePass" required class="form-control" />  
      </div>  
   
      <div>  
         <label>Confirm Password</label>  
         <input type="password" name="repeatPass" ng-model="repeatPass" required compare-to="livePass" class="form-control" />   
         <span class="error" ng-show="liveForm.repeatPass.$error.compareTo">  
            Passwords don't match.  
         </span>   
      </div>  
   
   </form>   
</div>  

AngularJs Source code-sample (index.js)

var liveApp = angular.module("liveApp", []);  
liveApp.controller("repeatCtrl", function ($scope)  
{  
    $scope.student = {  
        password: "",  
        repeatPassword: ""  
    };  
});  
liveApp.directive("compareTo", function ()  
{  
    return {  
        require: "ngModel",  
        scope:  
        {  
            repeatPassword: "=compareTo"  
        },  
        link: function (scope, element, attributes, paramval)  
        {  
            paramval.$validators.compareTo = function (val)  
            {  
                return val == scope.repeatPassword;  
            };  
            scope.$watch("repeatPassword", function ()  
            {  
                paramval.$validate();  
            });  
        }  
    };  
});  

angularjs password

Also Read :   Jquery Datatable listing json Server side in Php Mysql and Ajax

Example 2 : Confirm Password Validation in AngularJS

The compare-to angular directive:

var compareTo = function() {
    return {
        require: "ngModel",
        scope: {
            repeatPassword: "=compareTo"
        },
        link: function(scope, element, attributes, ngModel) {
             
            ngModel.$validators.compareTo = function(livemdlval) {
                return livemdlval == scope.repeatPassword;
            };
 
            scope.$watch("repeatPassword", function() {
                ngModel.$validate();
            });
        }
    };
};
 
module.directive("compareTo", compareTo);

We can simple use the angular directive inside of HTML(index.html):

<input type="password" name="repeatPassword" 
        ng-model="signup.student.repeatPassword"
        required 
        compare-to="signup.student.password" />
             
<div ng-messages="registrationForm.repeatPassword.$error"
      ng-messages-include="messages.html"></div>

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example





Example

I hope you have Got What is match password and confirm password in angularjs And how it works.I would Like to have FeedBack From My Blog(live24u.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(live24u.com) Are Most Always Welcome.