Question
HCL
IN
Last activity: 20 Aug 2024 2:15 EDT
How to remove spaces when we are entering number in Fiel
For India- Spaces are not aowed in the TAX number. Tax Number vaidation we can enter digits and some characters ".+>"up to 15 max
***Edited by Moderator Marije to change type from Pega Academy to Product***
-
Reply
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Maantic Inc
IN
If string has more duplicate spaces. you can use below function with expression and it will remove all the duplicate spaces from string.
For example: Lorem Ipsum Dolor 96 and you can remove the duplicate spaces and out put is Lorem Ipsum Dolor 96
@pxReplaceAllViaRegex("Lorem Ipsum Dolor 96","\\s+"," ")
HCL
IN
@SohamM95 when we select India In country It show TAX id and TAX number In TAX number - when enter any thing like we can enter digits and some characters ".+>"up to 15 max. ^[\\w.+-\\/\\\\]{1,15}$
Spaces are not allowed .
Maantic Inc
IN
What is your requirement exactly?
Updated: 23 Jul 2024 1:54 EDT
HCL
IN
when we select India In country It show TAX id and TAX number In TAX number - when enter any thing like we can enter digits and some characters ".+>"up to 15 max. ^[\\w.+-\\/\\\\]{1,15}$
Spaces are not allowed . By using Edit Validate rule , How can we write java code for removing spaces.
Updated: 24 Jul 2024 8:40 EDT
LTIMindtree
PL
Hi @saripalliy16834594 For displaying validation message you can use ootb- containsSpace edit validate rule.
(or)
for removing the spaces using Edit Input, try the below Java code.
java.util.StringTokenizer st = new java.util.StringTokenizer(theValue, " ");
String resultString=new String();
boolean bHasSpace = false;
while(st.hasMoreTokens())
{
resultString=resultString+(String)st.nextToken();
bHasSpace = true;
}
if (bHasSpace == true)
theValue=resultString;
HCL
IN
@Vamsi Krishna I tried with Above code , while saving its thowing error like
"This record has 1 error(s) in 1 place(s) .
line: -6 This method must return a result of type boolean
Compile failed."
Updated: 25 Jul 2024 5:53 EDT
LTIMindtree
PL
above code is for Edit Input rule.
for Edit Validate try the below code and check.
theProperty.setValue(theValue.replaceAll("\\s", ""));
return true;
HCL
IN
@Vamsi Krishna thankyou its working but small query in Tax number field No special characters taken expect + - / \ it can takes integers , alphabets.(but no special characters like @#$%^&*()).....except + - \ / can you suggest a code using edit validate.