- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Scenario:
I am asked to develop a Script Include that validates the password strength based on the following conditions:
Minimum length: 8 characters
Must contain at least one uppercase letter
Must contain at least one lowercase letter
Must contain at least one number
Must contain at least one special character
If the password does not meet these requirements, it should be flagged as “Weak Password”, otherwise as “Strong Password.”
How we can achieve this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
If your looking for custom approach, you can try this
function validatePasswordStrength(password) {
// Regular expressions for validation
var minLength = password.length >= 8;
var hasUppercase = /[A-Z]/.test(password);
var hasLowercase = /[a-z]/.test(password);
var hasNumber = /[0-9]/.test(password);
var hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
if (minLength && hasUppercase && hasLowercase && hasNumber && hasSpecialChar) {
return "Strong Password";
} else {
return "Weak Password";
}
}
Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Can you try the following for scripting,
You can configure the validation using Policies for latest release,
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
you can use the below in script include:-
ckStr: function(pwd) {
if (!pwd) return "Empty password!";
var strong = pwd.length >= 8 &&
/[A-Z]/.test(pwd) &&
/[a-z]/.test(pwd) &&
/[0-9]/.test(pwd) &&
/[^A-Za-z0-9]/.test(pwd);
return strong ? "Strong Password" : "Weak Password";
},
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
If your looking for custom approach, you can try this
function validatePasswordStrength(password) {
// Regular expressions for validation
var minLength = password.length >= 8;
var hasUppercase = /[A-Z]/.test(password);
var hasLowercase = /[a-z]/.test(password);
var hasNumber = /[0-9]/.test(password);
var hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
if (minLength && hasUppercase && hasLowercase && hasNumber && hasSpecialChar) {
return "Strong Password";
} else {
return "Weak Password";
}
}
Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Can you try the following for scripting,
You can configure the validation using Policies for latest release,
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
no scripting required, you can handle this with OOTB configuration
Configure the required strength for passwords
Configure your password policy
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
you can use the below in script include:-
ckStr: function(pwd) {
if (!pwd) return "Empty password!";
var strong = pwd.length >= 8 &&
/[A-Z]/.test(pwd) &&
/[a-z]/.test(pwd) &&
/[0-9]/.test(pwd) &&
/[^A-Za-z0-9]/.test(pwd);
return strong ? "Strong Password" : "Weak Password";
},
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/