Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Input form - avoiding special characters in text field

Avatar

Level 3

Hi Team,

In a custom input form, we have a text field. Here we need to avoid few special characters like @ $ % etc.,

How can i make it possible?

 

For example,

<input xpath="@textField"/>

 

Thanks and regards,

ParthaSarathy.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi ,

 

You can use Regex for this. 

 

In your form use Leave tag like below and use soapcall tag and specify new function which you will create in JavaScript file. 

<leave>

<soapCall name="functionName" service ="">

<param exprIn="[give full path of field you want to check]" type="string"/>

</leave>

 

Make sure : In Javascript file , function you define have syntax like below 

namespace_schema_fucntionName(test)

{

var res= test.match(); // Use regex here to find special character

if(res==null)

{

 alert("special character found")

}

}

 

Thanks,

Kapil

View solution in original post

4 Replies

Avatar

Community Advisor

Hi,

 

You can check on form save/close with:

<check expr="@textField not like '%@%' and ..."><error>Invalid character</error></check>

 

To replace *all* special characters with '_', at a schema level, use dataPolicy="identifier" on the attribute- no form work needed.

 

Thanks,

-Jon

Avatar

Level 3
Hi @Jonathon_wodnicki, 'not like' is not working. It throws a popup 'the operator 'not like' is not supported in the internal expression language'

Avatar

Correct answer by
Community Advisor

Hi ,

 

You can use Regex for this. 

 

In your form use Leave tag like below and use soapcall tag and specify new function which you will create in JavaScript file. 

<leave>

<soapCall name="functionName" service ="">

<param exprIn="[give full path of field you want to check]" type="string"/>

</leave>

 

Make sure : In Javascript file , function you define have syntax like below 

namespace_schema_fucntionName(test)

{

var res= test.match(); // Use regex here to find special character

if(res==null)

{

 alert("special character found")

}

}

 

Thanks,

Kapil

Avatar

Level 1

Hi Team,

I am facing a issue on web page, it not taking special character.

document.write(ctx.event.webAppFields.@longDescription);

Printing "world’s " instead of world's

Indra123_0-1641803517251.png

Please help here,

Thanks