Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This repository contains a ServiceNow Script Include + Client Script demo for enforcing password strength during user registration or password reset processes.
Overview

The goal is to ensure that any password set in ServiceNow (e.g., through a Catalog Item or custom form) follows strong security rules:
At least 8 characters
At least 1 uppercase letter
At least 1 lowercase letter
At least 1 number
At least 1 special character
If the rules are not met, the system flags the password as Weak Password.

Example :
Imagine you build a User Registration Catalog Item where a field Proposed Password is entered by the user.
On change of this field, the Client Script runs.
It calls the PasswordUtil Script Include.
If the password is weak, the form shows an inline error message, preventing weak password submissions.
This ensures consistent security enforcement across ServiceNow forms.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Class definition
var PasswordUtil = Class.create();
PasswordUtil.prototype = {
initialize: function() {},

/**
* checkStrength
* @param {String} pwd - The password string to evaluate
* @return {String} result - Returns "Strong Password" or "Weak Password"
*/
checkStrength: function(pwd) {
// If password is empty/null, return message
if (!pwd) return "Empty password!";

// Rules for strong password:
// 1. At least 8 characters
// 2. At least one uppercase letter
// 3. At least one lowercase letter
// 4. At least one number
// 5. At least one special character
var strong = pwd.length >= 8 &&
/[A-Z]/.test(pwd) && // has uppercase
/[a-z]/.test(pwd) && // has lowercase
/[0-9]/.test(pwd) && // has number
/[^A-Za-z0-9]/.test(pwd); // has special char

return strong ? "Strong Password" : "Weak Password";
},

type: 'PasswordUtil'
};
Loading