Question

how to prevent a user from entering special characters in input text field

Hi There, I came across this scenario where we prevent users to enter special characters in input text field, and below is the one exception

1. the user can enter hyphen (-) and apostrophe(')

thanks in advance

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
March 22, 2018 - 6:55am

Thanks for your comments, I found solution by using regular expression at Flow action's validation rule

@pxContainsViaRegex(Replace_your_Property_Here,"[^A-Za-z0-9-']",true)

Comments

Keep up to date on this post and subscribe to comments

Pega
March 21, 2018 - 10:44am

Hi,

you can use the edit validate rule, there is a rule named "isspecialcharacter", check whether it helps.

Pega
March 21, 2018 - 9:00pm

Hi,

you can use the below code on text input (select the text input fisrt using a appropiate selector)

$("input").keypress(function(e){
    var charCode = !e.charCode ? e.which : e.charCode;

    if( /*test for the special character */)
        e.preventDefault();
})

say if i want to block Hypen '-', then i will use the ascii code for it ie. if(charCode == 45 ),So it willnot allow me to type the hypen in textinput.

March 22, 2018 - 6:55am

Thanks for your comments, I found solution by using regular expression at Flow action's validation rule

@pxContainsViaRegex(Replace_your_Property_Here,"[^A-Za-z0-9-']",true)