Skip to content

Commit 1e688c4

Browse files
Pan card validation script (#1467)
* Script.js * readme.md
1 parent 705844e commit 1e688c4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function onSubmit() {
2+
// Get the value from the PAN field (replace 'u_pan_number' with your actual field name)
3+
var panNumber = g_form.getValue('u_pan_number');
4+
5+
// Regular expression for validating PAN card number
6+
var panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/;
7+
8+
// Validate the PAN number
9+
if (!panRegex.test(panNumber)) {
10+
alert('Please enter a valid PAN card number.');
11+
// Prevent the form from being submitted
12+
return false;
13+
}
14+
15+
// Allow the form to be submitted
16+
return true;
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Description
2+
This client script in ServiceNow is designed to validate the format of a PAN (Permanent Account Number) card during form submission.
3+
By ensuring that the PAN card number entered adheres to the expected format, this script enhances data integrity and user experience.
4+
If the entered PAN number is invalid, the script alerts the user, preventing form submission until a valid PAN number is provided.
5+
6+
Key Features
7+
8+
1. Format Validation: Checks PAN card format (5 letters, 4 digits, 1 letter).
9+
2. User Alerts: Provides immediate feedback for invalid entries.
10+
3. Submission Control: Prevents form submission with invalid PAN numbers.
11+
4. Customizable: Easily adjustable for different field names.
12+
5. Client-Side Efficiency: Quick validation without server delays.
13+
6. Data Integrity: Ensures only correctly formatted PAN numbers are accepted.

0 commit comments

Comments
 (0)