Hi there, I came across this scenario ,
- Restrict Users from entering these ~ , | three special characters in the test input and text area .
Can you please specify the exact Expression or code for this scenario ?
Thanks in adavance.
Hi there, I came across this scenario ,
Can you please specify the exact Expression or code for this scenario ?
Thanks in adavance.
β
Hi @Abinayakandan
Can you use below Custom Java code (I have mentioned 3 different ways, you can use anything).
Note: Recommended Method 3
Create one Edit Validate rule, then copy below code and paste.
You can use this edit validate rule into under advance tab of the property.
Note: Error Message your wish; you can change according to your needs.
β//--------------------Method:1--------------------//
for (int pos = 0, len = theValue.length(); pos < len; ++pos)
{
char c = theValue.charAt(pos);
int ascii =(int)c;
if ((ascii<0 || ascii>43) && (ascii<45 || ascii>123) && (ascii<125 || ascii>125) && (ascii<127 || ascii>127))
{
theProperty.addMessage("Not Allowed Special Characters ~ , |");
return false;
}
}
return true;
//---------------------Method:2--------------------//
for (int pos = 0, len = theValue.length(); pos < len; ++pos)
{
char c = theValue.charAt(pos);
int ascii =(int)c;
if (ascii==44 ) // This is blocking the Comma , Symbol
{
theProperty.addMessage("Not Allowed Special Characters ~ , |");
return false;
}
if(ascii==124) // This is blocking the | Symbol
{
theProperty.addMessage("Not Allowed Special Characters ~ , |");
return false;
}
if(ascii==126) // This is blocking ~ Symbol
{
theProperty.addMessage("Not Allowed Special Characters ~ , |");
return false;
}
}
return true;
//------------------------Method:3---------------------------//
for (int pos = 0, len = theValue.length(); pos < len; ++pos)
{
char c = theValue.charAt(pos);
int ascii =(int)c;
if ((ascii==44 ) || (ascii==124) || (ascii==126)) // This is blocking the , ~, |
{
theProperty.addMessage("Not Allowed Special Characters ~ , |");
return false;
}
}
return true;
I hope this will help you.
Thanks,
Ashok
@Bhumireddy thankyou , itβs working.
hi @Bhumireddy , we have one section , in that section we have many text input and text area . instead of giving for each property advance tab , did we have any solution for whole section that special character needs to be restrict?
Hi @Abinayakandan,
We have a validate rule, that is server-side validation. Even with that validation rule, you have to write the logic for all properties.
As per my knowledge, we cannot apply the whole section at once.
But you can reuse the Same Edit Validate rule for all properties those properties are available in that particular section.
Thanks,
Ashok