Skip to content
Merged
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Strong Username Validation Script
This script validates a username entered in a ServiceNow catalog item form. It prevents form submission if the username does not meet the required format.

### Validation Criteria
The username must start with a letter (a–z or A–Z).
It must be at least 6 characters long.
It can only contain letters and numbers.

## Usage
Add the script as an onSubmit client script in the catalog item. If the username is invalid, an error message is shown and the form is not submitted.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ function onSubmit() {

// Define the regex pattern for a strong username
var usernamePattern = /^[a-zA-Z][a-zA-Z0-9]{5,}$/;

// Regex explanation:
// ^ : Start of string
// [a-zA-Z] : First character must be a letter
// [a-zA-Z0-9] : Remaining characters can be letters or digits
// {5,} : At least 5 more characters (total minimum length = 6)
// $ : End of string


// Validate the username against the pattern
if (!usernamePattern.test(username)) {
Expand Down
Loading