42
Views
4
Comments
Solved
Restrict special characters in input field
Question

want to allow only alphanumeric keys in input field. 

mvp_badge
MVP
Rank: #91
Solution

Hi Poonam,

One more solution:

1) Add the below JS script to the Input widget --> onkeyup extended property as shown below

onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9]/g, '')"

Hope this helps you!


Regards,

Benjith Sam

mvp_badge
MVP
Rank: #91
Solution

Hi Poonam,

One more solution:

1) Add the below JS script to the Input widget --> onkeyup extended property as shown below

onkeyup="this.value=this.value.replace(/[^a-zA-Z0-9]/g, '')"

Hope this helps you!


Regards,

Benjith Sam

Rank: #109

Hi Poonam,

The simplest and fastest (performance-wise) way is to use the regular expression. 

^[a-zA-Z0-9]*$ It matches any alphanumeric string (no spaces).

Description:

^ : start of string
[ : beginning of character group
a-z : any lowercase letter
A-Z : any uppercase letter
0-9 : any digit
] : end of character group
* : zero or more of the given characters
$ : end of string

Regards,

Swatantra