Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Input form - avoiding special characters in text field

Partha18
Level 3
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
kapilKochar
Correct answer by
Community Advisor
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

3 Replies
wodnicki
Community Advisor
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

Partha18
Level 3
Level 3
Hi @wodnicki, 'not like' is not working. It throws a popup 'the operator 'not like' is not supported in the internal expression language'
kapilKochar
Correct answer by
Community Advisor
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