Input form - avoiding special characters in text field | Community
Skip to main content
Level 3
June 19, 2020
Solved

Input form - avoiding special characters in text field

  • June 19, 2020
  • 3 replies
  • 3616 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kapilKochar

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

3 replies

Jonathon_wodnicki
Community Advisor
Community Advisor
June 20, 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

Partha18Author
Level 3
June 22, 2020
Hi @jonathon_wodnicki, 'not like' is not working. It throws a popup 'the operator 'not like' is not supported in the internal expression language'
kapilKochar
kapilKocharAccepted solution
Level 6
June 22, 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

January 10, 2022

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

Please help here,

Thanks