Skip to main content

Password mismatch validation in angularjs

Angular using to apply password mismatch validation in the form. We need a password match validation, When i interred my password field value say for example admin(*****) and conform password field will inter match the same value from the field. The value are match means set flag for a variable is True or mismatched the value means it will set Fasle. 

Based this flag value to show the message form to apply directive of ng-show. This logic apply email validation also.

AngularJS:

var app = angular.module('frmVal',[]);
app.controller('FrmCtrl', function($scope){
    $scope.pwd = "";
    $scope.cpwd = "";
 
    $scope.isMatch = true;
 
    $scope.$watch('pwd', function(newValue, oldValue){
        if(newValue == $scope.cpwd)
        {
            $scope.isMatch = false;
        } else {
            $scope.isMatch = true;
        }
    });
    $scope.$watch('cpwd', function(newValue, oldValue){
        if(newValue == $scope.pwd)
        {
            $scope.isMatch = false;
        } else {
            $scope.isMatch = true;
        }
    });
});

HTML:
<div ng-app="frmVal">
    <div ng-controller="FrmCtrl">
       Password <input type="text" ng-model="pwd" /> <br/>
        Conform Password <input type="text" ng-model="cpwd" /><br/>
        <div class="error" ng-show="isMatch"> Do not Match</div>
    </div>
</div>

Result:
Demo

Comments

  1. After completing my course at online Angularjs training center, I started following this blog for revision of the subject and it really helped a lot to gain more knowledge.

    ReplyDelete

Post a Comment

Popular posts from this blog

How has lockdown impacted Indian farmers?

How has lockdown impacted Indian farmers?             Generally compare to other sectors it's not major impacted by our Indian farmers but we acceptable minor impacts. Here we separate major two farming cultures one is mono farming culture another one poly farming culture. Mono farming :             The major impacts from our Indian farmer for monoculture. Here I have briefly explained what are the things we had faced our local farmers. Here I explain two different crops type: Daily crops : * We harvest more than 100-kilo grams daily crops like brinjal but we unable to sell those in local markets. * We are unable to reach urban markets. * We don't have enough transport facilities. * We unable buy require fertilizer and other complements * In the early stage we are facing manpower shortage but later it's not an issue. * We unable to do value-added products. * Waste is very high for somedays Se...

How to use ng-href directive in AngularJS

ng-Href Directive                  ng-Href directive is hyper link markup to a text in angularJs. This hyperlink will change able to implement dynamic url {{hash}} value. Hash value to assign in a controller to happened user click event fire to assign dynamic url. This Value is undefined means it will return to 404 page. ng-Href directive Example  HTML:      <div ng-app="anchor">     <div ng-controller="anchorController">         <a ng-href="http://www.google.com" ng-click="show($event)">Anchor Tag</a>     </div>   </div> Javascript :  var anch = angular.module('anchor', []); anch.controller('anchorController',['$scope', '$window', function($scope, $window){     $scope.show = function(obj) {       $window.open(obj.target.href);     } }]); Result :  Dem...

Fiksu integration by cordova mobile application

Fiksu: A fiksu is a advertisement agency in various media domain. Especially in mobile application side more effectively analysis by mobile users. Their best to do the ads on your application and collective revenue  and pay to the yours. Fiksu Integration Steps:(Install Linux or Ubuntu) 1.  Create an account from fiksu site as following URL https://dashboard.fiksu.com/en/signin . 2.  Singin your credential from this site. 3. Download the fiksu SDK files Download . 4.Then open your terminal and type android command. Open Android SDK manager widget is select Extra package inside play related package list item is select and install it. 5. Now extract fiksu SDK downloaded and get Path details and execute following command. cordova plugin add com.fiksu.sdk --searchpath home/user/Fiksu-SDK-for-Cordova-1.2.0/Library/plugin --noregistry 6. Add the following code from your index.html inside of the javascrip blog. Android: onDeviceReady: function() { ...