how to validate my password in combination of lettters numaric and special class in angularjs?












0















am using angular validation in my login form. How to set password field validation in the combination of special character, letters, and numbers. so anyone can help me how to set my password?



my HTML code is,



        <div ng-app="loginApp">
<div ng-controller="loginController">
<div class="container">
<form name="loginForm" ng-submit="submit()">
<h3>Log In</h3>
<div class="row">
<div class="form-group col-md-3">
<label>User Name</label>
<input type="text" class="form-control"
id="username" ng-model="obj.username">
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label>Password</label>
<input type="password" class="form-control"
id="pass" ng-model="obj.password">
</div>
</div>
<div class="row">
<div class="form-group col-md-2">
<button type="submit" class="btn btn-primary">
Log In</button>
</div>
</form>
</form>
</div>
</div>
</div>


my controller is,



    angular.module('loginApp',)
.controller('loginController',function($scope){
$scope.obj={};

$scope.submit=function(){
alert('submit');
console.log( $scope.obj);
}

})









share|improve this question























  • You can check the password strength with zxcvbn module

    – Aleksey Solovey
    Nov 22 '18 at 9:24
















0















am using angular validation in my login form. How to set password field validation in the combination of special character, letters, and numbers. so anyone can help me how to set my password?



my HTML code is,



        <div ng-app="loginApp">
<div ng-controller="loginController">
<div class="container">
<form name="loginForm" ng-submit="submit()">
<h3>Log In</h3>
<div class="row">
<div class="form-group col-md-3">
<label>User Name</label>
<input type="text" class="form-control"
id="username" ng-model="obj.username">
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label>Password</label>
<input type="password" class="form-control"
id="pass" ng-model="obj.password">
</div>
</div>
<div class="row">
<div class="form-group col-md-2">
<button type="submit" class="btn btn-primary">
Log In</button>
</div>
</form>
</form>
</div>
</div>
</div>


my controller is,



    angular.module('loginApp',)
.controller('loginController',function($scope){
$scope.obj={};

$scope.submit=function(){
alert('submit');
console.log( $scope.obj);
}

})









share|improve this question























  • You can check the password strength with zxcvbn module

    – Aleksey Solovey
    Nov 22 '18 at 9:24














0












0








0








am using angular validation in my login form. How to set password field validation in the combination of special character, letters, and numbers. so anyone can help me how to set my password?



my HTML code is,



        <div ng-app="loginApp">
<div ng-controller="loginController">
<div class="container">
<form name="loginForm" ng-submit="submit()">
<h3>Log In</h3>
<div class="row">
<div class="form-group col-md-3">
<label>User Name</label>
<input type="text" class="form-control"
id="username" ng-model="obj.username">
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label>Password</label>
<input type="password" class="form-control"
id="pass" ng-model="obj.password">
</div>
</div>
<div class="row">
<div class="form-group col-md-2">
<button type="submit" class="btn btn-primary">
Log In</button>
</div>
</form>
</form>
</div>
</div>
</div>


my controller is,



    angular.module('loginApp',)
.controller('loginController',function($scope){
$scope.obj={};

$scope.submit=function(){
alert('submit');
console.log( $scope.obj);
}

})









share|improve this question














am using angular validation in my login form. How to set password field validation in the combination of special character, letters, and numbers. so anyone can help me how to set my password?



my HTML code is,



        <div ng-app="loginApp">
<div ng-controller="loginController">
<div class="container">
<form name="loginForm" ng-submit="submit()">
<h3>Log In</h3>
<div class="row">
<div class="form-group col-md-3">
<label>User Name</label>
<input type="text" class="form-control"
id="username" ng-model="obj.username">
</div>
</div>
<div class="row">
<div class="form-group col-md-3">
<label>Password</label>
<input type="password" class="form-control"
id="pass" ng-model="obj.password">
</div>
</div>
<div class="row">
<div class="form-group col-md-2">
<button type="submit" class="btn btn-primary">
Log In</button>
</div>
</form>
</form>
</div>
</div>
</div>


my controller is,



    angular.module('loginApp',)
.controller('loginController',function($scope){
$scope.obj={};

$scope.submit=function(){
alert('submit');
console.log( $scope.obj);
}

})






angularjs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 9:20









yazhini kyazhini k

1




1













  • You can check the password strength with zxcvbn module

    – Aleksey Solovey
    Nov 22 '18 at 9:24



















  • You can check the password strength with zxcvbn module

    – Aleksey Solovey
    Nov 22 '18 at 9:24

















You can check the password strength with zxcvbn module

– Aleksey Solovey
Nov 22 '18 at 9:24





You can check the password strength with zxcvbn module

– Aleksey Solovey
Nov 22 '18 at 9:24












2 Answers
2






active

oldest

votes


















0














Try



function validatePassword(str) {
var code, i, len;
for (i = 0, len = str.length; i < len; i++) {
code = str.charCodeAt(i);
if (!(code > 47 && code < 58) && // numeric (0-9)
!(code > 64 && code < 91) && // upper alpha (A-Z)
!(code > 96 && code < 123) && // lower alpha (a-z)
!(code == 32) && // space ( )
!(code == 45)) // dash (-)
// Extend your acceptable special characters here
{
return false;
}
}
return true;
},





share|improve this answer































    0














    Hi yazhini k you can check the strength of your password as follows:






    angular.module('loginApp',)
    .controller('loginController',function($scope){
    $scope.obj={};


    $scope.submit=function(){
    if((!/d/.test($scope.obj.password))){
    alert("password must contain digits");
    }
    if(!/[A-Z]/.test($scope.obj.password)){
    alert("password must contain uppercase letter");
    }
    if(!/[a-z]/.test($scope.obj.password)){
    alert("password must contain lowercase letter");
    }
    if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
    alert("password must contain special character");
    }
    console.log( $scope.obj);
    }

    })

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
    <div ng-app="loginApp">
    <div ng-controller="loginController">
    <div class="container">
    <form name="loginForm" ng-submit="submit()">
    <h3>Log In</h3>
    <div class="row">
    <div class="form-group col-md-3">
    <label>User Name</label>
    <input type="text" class="form-control"
    id="username" ng-model="obj.username">
    </div>
    </div>
    <div class="row">
    <div class="form-group col-md-3">
    <label>Password</label>
    <input type="password" class="form-control"
    id="pass" ng-model="obj.password">
    </div>
    </div>
    <div class="row">
    <div class="form-group col-md-2">
    <button type="submit" class="btn btn-primary">
    Log In</button>
    </div>
    </form>
    </form>
    </div>
    </div>
    </div>








    share|improve this answer
























    • thank you sarath.. it is working

      – yazhini k
      Nov 22 '18 at 10:53











    • you are welcome :)

      – Sarath Raj
      Nov 22 '18 at 10:59











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427526%2fhow-to-validate-my-password-in-combination-of-lettters-numaric-and-special-class%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try



    function validatePassword(str) {
    var code, i, len;
    for (i = 0, len = str.length; i < len; i++) {
    code = str.charCodeAt(i);
    if (!(code > 47 && code < 58) && // numeric (0-9)
    !(code > 64 && code < 91) && // upper alpha (A-Z)
    !(code > 96 && code < 123) && // lower alpha (a-z)
    !(code == 32) && // space ( )
    !(code == 45)) // dash (-)
    // Extend your acceptable special characters here
    {
    return false;
    }
    }
    return true;
    },





    share|improve this answer




























      0














      Try



      function validatePassword(str) {
      var code, i, len;
      for (i = 0, len = str.length; i < len; i++) {
      code = str.charCodeAt(i);
      if (!(code > 47 && code < 58) && // numeric (0-9)
      !(code > 64 && code < 91) && // upper alpha (A-Z)
      !(code > 96 && code < 123) && // lower alpha (a-z)
      !(code == 32) && // space ( )
      !(code == 45)) // dash (-)
      // Extend your acceptable special characters here
      {
      return false;
      }
      }
      return true;
      },





      share|improve this answer


























        0












        0








        0







        Try



        function validatePassword(str) {
        var code, i, len;
        for (i = 0, len = str.length; i < len; i++) {
        code = str.charCodeAt(i);
        if (!(code > 47 && code < 58) && // numeric (0-9)
        !(code > 64 && code < 91) && // upper alpha (A-Z)
        !(code > 96 && code < 123) && // lower alpha (a-z)
        !(code == 32) && // space ( )
        !(code == 45)) // dash (-)
        // Extend your acceptable special characters here
        {
        return false;
        }
        }
        return true;
        },





        share|improve this answer













        Try



        function validatePassword(str) {
        var code, i, len;
        for (i = 0, len = str.length; i < len; i++) {
        code = str.charCodeAt(i);
        if (!(code > 47 && code < 58) && // numeric (0-9)
        !(code > 64 && code < 91) && // upper alpha (A-Z)
        !(code > 96 && code < 123) && // lower alpha (a-z)
        !(code == 32) && // space ( )
        !(code == 45)) // dash (-)
        // Extend your acceptable special characters here
        {
        return false;
        }
        }
        return true;
        },






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 10:19









        holydragonholydragon

        1,5232618




        1,5232618

























            0














            Hi yazhini k you can check the strength of your password as follows:






            angular.module('loginApp',)
            .controller('loginController',function($scope){
            $scope.obj={};


            $scope.submit=function(){
            if((!/d/.test($scope.obj.password))){
            alert("password must contain digits");
            }
            if(!/[A-Z]/.test($scope.obj.password)){
            alert("password must contain uppercase letter");
            }
            if(!/[a-z]/.test($scope.obj.password)){
            alert("password must contain lowercase letter");
            }
            if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
            alert("password must contain special character");
            }
            console.log( $scope.obj);
            }

            })

            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
            <div ng-app="loginApp">
            <div ng-controller="loginController">
            <div class="container">
            <form name="loginForm" ng-submit="submit()">
            <h3>Log In</h3>
            <div class="row">
            <div class="form-group col-md-3">
            <label>User Name</label>
            <input type="text" class="form-control"
            id="username" ng-model="obj.username">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-3">
            <label>Password</label>
            <input type="password" class="form-control"
            id="pass" ng-model="obj.password">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-2">
            <button type="submit" class="btn btn-primary">
            Log In</button>
            </div>
            </form>
            </form>
            </div>
            </div>
            </div>








            share|improve this answer
























            • thank you sarath.. it is working

              – yazhini k
              Nov 22 '18 at 10:53











            • you are welcome :)

              – Sarath Raj
              Nov 22 '18 at 10:59
















            0














            Hi yazhini k you can check the strength of your password as follows:






            angular.module('loginApp',)
            .controller('loginController',function($scope){
            $scope.obj={};


            $scope.submit=function(){
            if((!/d/.test($scope.obj.password))){
            alert("password must contain digits");
            }
            if(!/[A-Z]/.test($scope.obj.password)){
            alert("password must contain uppercase letter");
            }
            if(!/[a-z]/.test($scope.obj.password)){
            alert("password must contain lowercase letter");
            }
            if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
            alert("password must contain special character");
            }
            console.log( $scope.obj);
            }

            })

            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
            <div ng-app="loginApp">
            <div ng-controller="loginController">
            <div class="container">
            <form name="loginForm" ng-submit="submit()">
            <h3>Log In</h3>
            <div class="row">
            <div class="form-group col-md-3">
            <label>User Name</label>
            <input type="text" class="form-control"
            id="username" ng-model="obj.username">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-3">
            <label>Password</label>
            <input type="password" class="form-control"
            id="pass" ng-model="obj.password">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-2">
            <button type="submit" class="btn btn-primary">
            Log In</button>
            </div>
            </form>
            </form>
            </div>
            </div>
            </div>








            share|improve this answer
























            • thank you sarath.. it is working

              – yazhini k
              Nov 22 '18 at 10:53











            • you are welcome :)

              – Sarath Raj
              Nov 22 '18 at 10:59














            0












            0








            0







            Hi yazhini k you can check the strength of your password as follows:






            angular.module('loginApp',)
            .controller('loginController',function($scope){
            $scope.obj={};


            $scope.submit=function(){
            if((!/d/.test($scope.obj.password))){
            alert("password must contain digits");
            }
            if(!/[A-Z]/.test($scope.obj.password)){
            alert("password must contain uppercase letter");
            }
            if(!/[a-z]/.test($scope.obj.password)){
            alert("password must contain lowercase letter");
            }
            if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
            alert("password must contain special character");
            }
            console.log( $scope.obj);
            }

            })

            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
            <div ng-app="loginApp">
            <div ng-controller="loginController">
            <div class="container">
            <form name="loginForm" ng-submit="submit()">
            <h3>Log In</h3>
            <div class="row">
            <div class="form-group col-md-3">
            <label>User Name</label>
            <input type="text" class="form-control"
            id="username" ng-model="obj.username">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-3">
            <label>Password</label>
            <input type="password" class="form-control"
            id="pass" ng-model="obj.password">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-2">
            <button type="submit" class="btn btn-primary">
            Log In</button>
            </div>
            </form>
            </form>
            </div>
            </div>
            </div>








            share|improve this answer













            Hi yazhini k you can check the strength of your password as follows:






            angular.module('loginApp',)
            .controller('loginController',function($scope){
            $scope.obj={};


            $scope.submit=function(){
            if((!/d/.test($scope.obj.password))){
            alert("password must contain digits");
            }
            if(!/[A-Z]/.test($scope.obj.password)){
            alert("password must contain uppercase letter");
            }
            if(!/[a-z]/.test($scope.obj.password)){
            alert("password must contain lowercase letter");
            }
            if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
            alert("password must contain special character");
            }
            console.log( $scope.obj);
            }

            })

            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
            <div ng-app="loginApp">
            <div ng-controller="loginController">
            <div class="container">
            <form name="loginForm" ng-submit="submit()">
            <h3>Log In</h3>
            <div class="row">
            <div class="form-group col-md-3">
            <label>User Name</label>
            <input type="text" class="form-control"
            id="username" ng-model="obj.username">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-3">
            <label>Password</label>
            <input type="password" class="form-control"
            id="pass" ng-model="obj.password">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-2">
            <button type="submit" class="btn btn-primary">
            Log In</button>
            </div>
            </form>
            </form>
            </div>
            </div>
            </div>








            angular.module('loginApp',)
            .controller('loginController',function($scope){
            $scope.obj={};


            $scope.submit=function(){
            if((!/d/.test($scope.obj.password))){
            alert("password must contain digits");
            }
            if(!/[A-Z]/.test($scope.obj.password)){
            alert("password must contain uppercase letter");
            }
            if(!/[a-z]/.test($scope.obj.password)){
            alert("password must contain lowercase letter");
            }
            if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
            alert("password must contain special character");
            }
            console.log( $scope.obj);
            }

            })

            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
            <div ng-app="loginApp">
            <div ng-controller="loginController">
            <div class="container">
            <form name="loginForm" ng-submit="submit()">
            <h3>Log In</h3>
            <div class="row">
            <div class="form-group col-md-3">
            <label>User Name</label>
            <input type="text" class="form-control"
            id="username" ng-model="obj.username">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-3">
            <label>Password</label>
            <input type="password" class="form-control"
            id="pass" ng-model="obj.password">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-2">
            <button type="submit" class="btn btn-primary">
            Log In</button>
            </div>
            </form>
            </form>
            </div>
            </div>
            </div>





            angular.module('loginApp',)
            .controller('loginController',function($scope){
            $scope.obj={};


            $scope.submit=function(){
            if((!/d/.test($scope.obj.password))){
            alert("password must contain digits");
            }
            if(!/[A-Z]/.test($scope.obj.password)){
            alert("password must contain uppercase letter");
            }
            if(!/[a-z]/.test($scope.obj.password)){
            alert("password must contain lowercase letter");
            }
            if(!/[ !@#$%^&*()_+-=[]{};':"\|,.<>/?]/.test($scope.obj.password)){
            alert("password must contain special character");
            }
            console.log( $scope.obj);
            }

            })

            <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
            <div ng-app="loginApp">
            <div ng-controller="loginController">
            <div class="container">
            <form name="loginForm" ng-submit="submit()">
            <h3>Log In</h3>
            <div class="row">
            <div class="form-group col-md-3">
            <label>User Name</label>
            <input type="text" class="form-control"
            id="username" ng-model="obj.username">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-3">
            <label>Password</label>
            <input type="password" class="form-control"
            id="pass" ng-model="obj.password">
            </div>
            </div>
            <div class="row">
            <div class="form-group col-md-2">
            <button type="submit" class="btn btn-primary">
            Log In</button>
            </div>
            </form>
            </form>
            </div>
            </div>
            </div>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 22 '18 at 10:29









            Sarath RajSarath Raj

            275




            275













            • thank you sarath.. it is working

              – yazhini k
              Nov 22 '18 at 10:53











            • you are welcome :)

              – Sarath Raj
              Nov 22 '18 at 10:59



















            • thank you sarath.. it is working

              – yazhini k
              Nov 22 '18 at 10:53











            • you are welcome :)

              – Sarath Raj
              Nov 22 '18 at 10:59

















            thank you sarath.. it is working

            – yazhini k
            Nov 22 '18 at 10:53





            thank you sarath.. it is working

            – yazhini k
            Nov 22 '18 at 10:53













            you are welcome :)

            – Sarath Raj
            Nov 22 '18 at 10:59





            you are welcome :)

            – Sarath Raj
            Nov 22 '18 at 10:59


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427526%2fhow-to-validate-my-password-in-combination-of-lettters-numaric-and-special-class%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python