From 9fab29e91b2def12b40342125b5b2333055cd2d4 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 17:11:19 +0530 Subject: [PATCH 1/8] Create Adhaar Validation Script --- .../Regex Validation/Adhaar Validation Script | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script new file mode 100644 index 0000000000..c12468d3b9 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script @@ -0,0 +1,16 @@ +function onSubmit() { + /* + Adhaar validation script. + */ + g_form.hideFieldMsg('adhaar'); + var adhrNum = g_form.getValue('adhaar'); // adhaar variable name + var adharReg = /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/; // adhaar regex + var regex = new RegExp(adharReg); + + if (!regex.test(adhrNum)) { + g_form.clearValue('adhaar'); // clear field value + g_form.showFieldMsg('adhaar', "Please enter valid adhaar number", 'error', true); + return false; // stop form submission + } + +} From 5d919f9f9f4ac27d91dac2d2e86a998f4272e001 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 17:13:43 +0530 Subject: [PATCH 2/8] Update README.md --- .../Catalog Client Script/Regex Validation/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/README.md b/Client-Side Components/Catalog Client Script/Regex Validation/README.md index f4bcb7aff4..554a9a64d4 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/README.md +++ b/Client-Side Components/Catalog Client Script/Regex Validation/README.md @@ -1,5 +1,12 @@ # Regular Expression on Catalog Client script - + +***************** +8th october: +This script will validate valid Adhaar number. +Adhaar is a 12 digit unique identification number issues by UIDAI in India. +The script will validate Adhaar through regex and if it is not valid, variable is cleared with field message. + +***************** With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message below the variable. Of course you can use Email type variable as well but you cannot have a formatted error message. * [Click here for script](script.js) From d1d08a2864c102e4775ac3a2c8f4447b2fe5dd24 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 17:14:54 +0530 Subject: [PATCH 3/8] Update Adhaar Validation Script --- .../Regex Validation/Adhaar Validation Script | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script index c12468d3b9..0f24fcd842 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script +++ b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script @@ -1,8 +1,10 @@ function onSubmit() { - /* + + g_form.hideFieldMsg('adhaar'); // hide previous field mesage. + /* Adhaar validation script. */ - g_form.hideFieldMsg('adhaar'); + var adhrNum = g_form.getValue('adhaar'); // adhaar variable name var adharReg = /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/; // adhaar regex var regex = new RegExp(adharReg); From 89f7deff5ce0c4a518bf0065186076413cda8160 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:10:24 +0530 Subject: [PATCH 4/8] Update Adhaar Validation Script Comments updated --- .../Regex Validation/Adhaar Validation Script | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script index 0f24fcd842..7baa89bc47 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script +++ b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script @@ -1,9 +1,17 @@ function onSubmit() { g_form.hideFieldMsg('adhaar'); // hide previous field mesage. - /* - Adhaar validation script. - */ + /* + Adhaar validation script. + + /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/ + // ^ → Start of the string + // [2-9] → The first digit must be between 2 and 9 + // [0-9]{3} → Followed by exactly 3 digits (0–9) + // [0-9]{4} → Followed by exactly 4 digits (0–9) + // [0-9]{4} → Followed by exactly 4 digits (0–9) + // $ → End of the string + */ var adhrNum = g_form.getValue('adhaar'); // adhaar variable name var adharReg = /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/; // adhaar regex From 966c5310fa0c9c82744a3a992de37350f9a7f3e0 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:12:31 +0530 Subject: [PATCH 5/8] Update README.md --- .../Catalog Client Script/Regex Validation/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/README.md b/Client-Side Components/Catalog Client Script/Regex Validation/README.md index 554a9a64d4..83fc4b78e5 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/README.md +++ b/Client-Side Components/Catalog Client Script/Regex Validation/README.md @@ -3,7 +3,7 @@ ***************** 8th october: This script will validate valid Adhaar number. -Adhaar is a 12 digit unique identification number issues by UIDAI in India. +Adhaar is a 12 digit unique identification number issues by UIDAI in India for Indian Residents. The script will validate Adhaar through regex and if it is not valid, variable is cleared with field message. ***************** From 3ea2ec1045c0abfb933a27898b94abd7b628ff6c Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:13:29 +0530 Subject: [PATCH 6/8] Update Adhaar Validation Script --- .../Regex Validation/Adhaar Validation Script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script index 7baa89bc47..9a16039144 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script +++ b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script @@ -3,7 +3,7 @@ function onSubmit() { g_form.hideFieldMsg('adhaar'); // hide previous field mesage. /* Adhaar validation script. - + Adhaar is a 12 digit unique identification number issues by UIDAI in India for Indian Residents. /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/ // ^ → Start of the string // [2-9] → The first digit must be between 2 and 9 From 067a3de8612318d2f5c47df9bed68797c10f077b Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:18:31 +0530 Subject: [PATCH 7/8] Update README.md --- .../Regex Validation/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/README.md b/Client-Side Components/Catalog Client Script/Regex Validation/README.md index 83fc4b78e5..3b6f372343 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/README.md +++ b/Client-Side Components/Catalog Client Script/Regex Validation/README.md @@ -3,8 +3,19 @@ ***************** 8th october: This script will validate valid Adhaar number. -Adhaar is a 12 digit unique identification number issues by UIDAI in India for Indian Residents. +Adhaar is a 12 digit unique identification number issues by Unique Identification Authority of India (UIDAI) for Indian Residents. The script will validate Adhaar through regex and if it is not valid, variable is cleared with field message. +For Catalog variables Preferred OOB method is listed here : https://www.servicenow.com/docs/bundle/xanadu-servicenow-platform/page/product/service-catalog-management/task/define-regex-vrble.html . The same regex can be defined in "Variable Validation Regex" module. +For Normal fields, this entire scriopt can be used. + +Regex details : +/^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/ +// ^ → Start of the string +// [2-9] → The first digit must be between 2 and 9 +// [0-9]{3} → Followed by exactly 3 digits (0–9) +// [0-9]{4} → Followed by exactly 4 digits (0–9) +// [0-9]{4} → Followed by exactly 4 digits (0–9) +// $ → End of the string ***************** With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message below the variable. Of course you can use Email type variable as well but you cannot have a formatted error message. From dc7a240d2e39d7492b3ae560c2ad65c67232a6c2 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:35:36 +0530 Subject: [PATCH 8/8] Update README.md --- .../Regex Validation/README.md | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Client-Side Components/Catalog Client Script/Regex Validation/README.md b/Client-Side Components/Catalog Client Script/Regex Validation/README.md index 3b6f372343..7af8396178 100644 --- a/Client-Side Components/Catalog Client Script/Regex Validation/README.md +++ b/Client-Side Components/Catalog Client Script/Regex Validation/README.md @@ -1,27 +1,39 @@ + # Regular Expression on Catalog Client script ***************** + 8th october: -This script will validate valid Adhaar number. -Adhaar is a 12 digit unique identification number issues by Unique Identification Authority of India (UIDAI) for Indian Residents. -The script will validate Adhaar through regex and if it is not valid, variable is cleared with field message. -For Catalog variables Preferred OOB method is listed here : https://www.servicenow.com/docs/bundle/xanadu-servicenow-platform/page/product/service-catalog-management/task/define-regex-vrble.html . The same regex can be defined in "Variable Validation Regex" module. -For Normal fields, this entire scriopt can be used. + +This script will validate the Adhaar number. + +Adhaar is a 12 digit unique identification number issued by the Unique Identification Authority of India (UIDAI) for Indian residents. + +The script will validate Adhaar through regex, and if it is not valid, the variable is cleared with a field message. + +The preferred OOB method for catalog variables is listed here : https://www.servicenow.com/docs/bundle/xanadu-servicenow-platform/page/product/service-catalog-management/task/define-regex-vrble.html . The same regex can be defined in "Variable Validation Regex" module. + Regex details : + /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/ + // ^ → Start of the string + // [2-9] → The first digit must be between 2 and 9 + // [0-9]{3} → Followed by exactly 3 digits (0–9) + // [0-9]{4} → Followed by exactly 4 digits (0–9) + // [0-9]{4} → Followed by exactly 4 digits (0–9) + // $ → End of the string ***************** -With the help of this code you can easily validate the input value from the user and if it's not a email format you can clear and throw a error message below the variable. Of course you can use Email type variable as well but you cannot have a formatted error message. - -* [Click here for script](script.js) +With the help of this code, you can easily validate the input value from the user. If it is not an Adhaar, you can clear it and throw an error message below the variable. The same validation can be used for fields instead of variables. +* [Click here for script](script.js)