how to validate my password in combination of lettters numaric and special class in angularjs?
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
add a comment |
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
You can check the password strength withzxcvbn
module
– Aleksey Solovey
Nov 22 '18 at 9:24
add a comment |
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
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
angularjs
asked Nov 22 '18 at 9:20
yazhini kyazhini k
1
1
You can check the password strength withzxcvbn
module
– Aleksey Solovey
Nov 22 '18 at 9:24
add a comment |
You can check the password strength withzxcvbn
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
add a comment |
2 Answers
2
active
oldest
votes
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;
},
add a comment |
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>
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
},
add a comment |
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;
},
add a comment |
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;
},
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;
},
answered Nov 22 '18 at 10:19
holydragonholydragon
1,5232618
1,5232618
add a comment |
add a comment |
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>
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
add a comment |
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>
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
add a comment |
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>
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>
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
You can check the password strength with
zxcvbn
module– Aleksey Solovey
Nov 22 '18 at 9:24