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

@saripalliy16834594

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+”," ")

@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.

[1]{1,15}$

Spaces are not allowed .


  1. \w.±\/\\ ↩︎

@SohamM95
Example.png

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. [1]{1,15}$

Spaces are not allowed .

By using Edit Validate rule , How can we write java code for removing spaces.


  1. \w.±\/\\ ↩︎

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;

@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."

Hi @saripalliy16834594,

above code is for Edit Input rule.

for Edit Validate try the below code and check.

theProperty.setValue(theValue.replaceAll(“\s”, “”));

return true;

@saripalliy16834594

What is your requirement exactly?

@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.