File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Regular Expressions/PAN Card Validation Script Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments