Adhaar validation script#1945
Conversation
| */ | ||
|
|
||
| var adhrNum = g_form.getValue('adhaar'); // adhaar variable name | ||
| var adharReg = /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/; // adhaar regex |
There was a problem hiding this comment.
Break down the regex in the comment and readme so users know what is checked.
I would include what Adhaar is, as it is specific to India "Aadhaar is a 12-digit unique identification number issued by the Unique Identification Authority of India (UIDAI) to residents of India".
Then break down the regex:
/^[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 adharReg = /^[2-9][0-9]{3}[0-9]{4}[0-9]{4}$/; // adhaar regex | ||
| var regex = new RegExp(adharReg); | ||
|
|
||
| if (!regex.test(adhrNum)) { |
There was a problem hiding this comment.
There is OOTB functionality that allows for this regex to be evaluated. Please have a look at this: https://www.servicenow.com/community/developer-articles/field-validation-regular-expressions/ta-p/2321095
| 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. |
There was a problem hiding this comment.
Explain what the regex does/how it is build up.
| 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. |
There was a problem hiding this comment.
As stated, include a comment that there is OOTB functionality that is prefered over this.
PR Description:
replace this with your description
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions