- Posts: 2
- Thank you received: 1
Apply regex password requirements
- AVENADesigns
-
Topic Author
- Offline
Less
More
14 years 1 week ago #65660
by AVENADesigns
Apply regex password requirements was created by AVENADesigns
Hello, I really hope someone can help me with this. I'm new to Javascript, so I really don't know where to start...
I've been looking extensively online and on this forum on how to apply these requirements to the Hikashop registration page:
- The password to successfully register must be at least 8 characters long
- Must consist of at least one Uppercase, Lowercase, Number and Non-alpha numeric character
I'm pretty sure the file I need to be editing is hikashop.js and the code that needs to be added is:
This is the code that is currently there:
Where inside this code would I place the modification to achieve the desired effect?
I've been looking extensively online and on this forum on how to apply these requirements to the Hikashop registration page:
- The password to successfully register must be at least 8 characters long
- Must consist of at least one Uppercase, Lowercase, Number and Non-alpha numeric character
I'm pretty sure the file I need to be editing is hikashop.js and the code that needs to be added is:
Code:
if (password.length < 8)
alert("bad password");
var hasUpperCase = /[A-Z]/.test(password);
var hasLowerCase = /[a-z]/.test(password);
var hasNumbers = /\d/.test(password);
var hasNonalphas = /\W/.test(password);
if (hasUpperCase + hasLowerCase + hasNumbers + hasNonalphas < 3)
alert("bad password");
This is the code that is currently there:
Code:
if(type=='register'){
//check password
if(typeof varform.elements['data[register][password]'] != 'undefined' && typeof varform.elements['data[register][password2]'] != 'undefined'){
passwd = varform.elements['data[register][password]'];
passwd2 = varform.elements['data[register][password2]'];
if(passwd.value!=passwd2.value){
alert(hikashop['password_different']);
return false;
}
}
Where inside this code would I place the modification to achieve the desired effect?
The following user(s) said Thank You: Lumiga
Please Log in or Create an account to join the conversation.
14 years 1 week ago #65681
by nicolas
Replied by nicolas on topic Re: Apply regex password requirements
You should add the code:
before the line:
if(passwd.value!=passwd2.value){
Code:
password = passwd.value;
if (password.length < 8){
alert("bad password");
return false;
}
var hasUpperCase = /[A-Z]/.test(password);
var hasLowerCase = /[a-z]/.test(password);
var hasNumbers = /\d/.test(password);
var hasNonalphas = /\W/.test(password);
if (hasUpperCase + hasLowerCase + hasNumbers + hasNonalphas < 3){
alert("bad password");
return false;
}
before the line:
if(passwd.value!=passwd2.value){
The following user(s) said Thank You: AVENADesigns, Lumiga
Please Log in or Create an account to join the conversation.
- AVENADesigns
-
Topic Author
- Offline
Less
More
- Posts: 2
- Thank you received: 1
14 years 1 week ago #65734
by AVENADesigns
Replied by AVENADesigns on topic Re: Apply regex password requirements
This worked wonderfully! Thank you!
Please Log in or Create an account to join the conversation.
Time to create page: 0.150 seconds