Question
Infosys Ltd
IN
Last activity: 29 Nov 2022 6:38 EST
Edit validate Rule creation
I want to give validation condition to text property like integers are not allowed only alphabets and special characters are allow. length should not exceed 20 characters how can I achieve this using edit validate rule(Java code ). I want to throw error messages as well when some one enters integer and exceed 20 characters limit.Both error messages should display at same time.
For Ex. "Length should not exceed 20 characters"
Only Alphabets and specila characters are allowed.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Updated: 22 Nov 2022 5:50 EST
Tata Consultancy Services
IN
Hi @PallaviI
1. You can use "AlphabeticValidation" OOTB Rule and Under Advanced TAB of the your Property
Note: It will allow only Alphabetics it means: Check if the specified string contains all letters. (Spaces also not allowed)
2. You mention the max length of the text under Advanced Tab of the your Property
I hope this will hep you,
Thanks,
Ashok
Infosys Ltd
IN
@BhumireddyI want to allow only alphabetic and special characters I need to restrict Integers how can I achieve this.
Thanks,
Pallavi Iche
Updated: 22 Nov 2022 15:49 EST
Tata Consultancy Services
IN
Hi @PallaviI
Records --> Data Model --> Edit Validate and Click Create for New Rule Creation Naming Convention your Wish: AlphaSpecialValidation
Paste the below Code into Java Source Workspace
Note : This is a Our Own Rule, it is not a OOTB Rule.
-------------------------------------------------------------------------------------
for (int pos = 0, len = theValue.length(); pos < len; ++pos)
{
char c = theValue.charAt(pos);
int ascii = (int)c;
if ((ascii<32 || ascii>47) && (ascii<58 || ascii>127))
{
theProperty.addMessage("Only Allowed Alphabets and Special Characters Eg: ABC !@#$");
return false;
}
}
return true;
-----------------------------------------------------------------------------------------
ASCII Table
Hi @PallaviI
Records --> Data Model --> Edit Validate and Click Create for New Rule Creation Naming Convention your Wish: AlphaSpecialValidation
Paste the below Code into Java Source Workspace
Note : This is a Our Own Rule, it is not a OOTB Rule.
-------------------------------------------------------------------------------------
for (int pos = 0, len = theValue.length(); pos < len; ++pos)
{
char c = theValue.charAt(pos);
int ascii = (int)c;
if ((ascii<32 || ascii>47) && (ascii<58 || ascii>127))
{
theProperty.addMessage("Only Allowed Alphabets and Special Characters Eg: ABC !@#$");
return false;
}
}
return true;
-----------------------------------------------------------------------------------------
ASCII Table
https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html
Note: Here warning message your wish, if you want edit you can edit message in double quotes
Then Save and the Checkin the Rule
Then Go to Property and Under Advance TAB You Can Mention Maximum Length: 20 and Search/Press Down Key Button Under Use Validate "AlphaSpecialValidation"
I hope this will help you,
Thanks,
Ashok
Infosys Ltd
IN
@Bhumireddythank you so much
Infosys Ltd
IN
@BhumireddyIf I want to show this both error messages(length validation error message, alphabets and special characters )simultaneously how can I achieve this using one single Edit Validate rule (java code).
Thanks.
Tata Consultancy Services
IN
Hi @PallaviI
Already we are restricted the length of the letters, it will not allow the more than 20 alphabets/special characters.
If you want display the message you can just edit
theProperty.addMessage("Only Allowed Alphabets and Special Characters Eg: ABC !@#$");
You can Replace above line of code with below line.
theProperty.addMessage("It will allow only maximum characters 20 and Only Allowed Alphabets and Special Characters Eg: ABC !@#$");
I hope this will help you,
Thanks,
Ashok
Updated: 29 Nov 2022 2:35 EST
Infosys Ltd
IN
@Bhumireddyif user enters more than 20 characters not integers so at that time I want to display only one error message like length should not exceed 20 characters and same when he enters less than 20 characters and enter any integer then another error message should populate like only alphabets and special characters are allowed.
If he enter more than 20 char. And integers then both error messages should populate.
Tata Consultancy Services
IN
Hi @PallaviI User don't have option to enter more than 20 letters, we are strictly restricted to 20 letters. Under Advanced TAB---> Max Length.
I hope you understand. Thanks,
Ashok
Infosys Ltd
IN
@Bhumireddy yeah but I want seperate error message for that as well like length should not exceed 20 characters
Eclatprime Digital Private Limited
IN