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..0f24fcd842 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Regex Validation/Adhaar Validation Script @@ -0,0 +1,18 @@ +function onSubmit() { + + g_form.hideFieldMsg('adhaar'); // hide previous field mesage. + /* + Adhaar validation script. + */ + + 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 + } + +} 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)