Input form - avoiding special characters in text field

Avatar

Avatar

Partha18

Avatar

Partha18

Partha18

19-06-2020

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

kapilKochar

MVP

Avatar

kapilKochar

MVP

kapilKochar
MVP

21-06-2020

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

Answers (1)

Answers (1)

Avatar

Avatar

wodnicki

MVP

Avatar

wodnicki

MVP

wodnicki
MVP

19-06-2020

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