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
17 changes: 17 additions & 0 deletions Regular Expressions/PAN Card Validation Script/Script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function onSubmit() {
// Get the value from the PAN field (replace 'u_pan_number' with your actual field name)
var panNumber = g_form.getValue('u_pan_number');

// Regular expression for validating PAN card number
var panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/;

// Validate the PAN number
if (!panRegex.test(panNumber)) {
alert('Please enter a valid PAN card number.');
// Prevent the form from being submitted
return false;
}

// Allow the form to be submitted
return true;
}
13 changes: 13 additions & 0 deletions Regular Expressions/PAN Card Validation Script/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Description
This client script in ServiceNow is designed to validate the format of a PAN (Permanent Account Number) card during form submission.
By ensuring that the PAN card number entered adheres to the expected format, this script enhances data integrity and user experience.
If the entered PAN number is invalid, the script alerts the user, preventing form submission until a valid PAN number is provided.

Key Features

1. Format Validation: Checks PAN card format (5 letters, 4 digits, 1 letter).
2. User Alerts: Provides immediate feedback for invalid entries.
3. Submission Control: Prevents form submission with invalid PAN numbers.
4. Customizable: Easily adjustable for different field names.
5. Client-Side Efficiency: Quick validation without server delays.
6. Data Integrity: Ensures only correctly formatted PAN numbers are accepted.
Loading