Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to change my script object to include use of special character?

Avatar

Level 2

I have a "myScriptObject" as part of my form.

I want to allow the user to use an asterisk as well as alpha, space, hypen and comma characters.

Where do I change the following script object?

Function: This function will allow alpha, space, hyphen and comma characters

Description: To validate input instantly while the user types, as opposed to letting the user type any characters into the field and then waiting till the user moves to the next field or attempts submission of the form before running the validation rule and invoking a message box with a validation fail message - to which they need to click OK and go back to the field.

**************************************************************************************/

function KeyStrokeAlpha(){

var regEx = new RegExp();

regEx.compile("[a-z A-Z \\s \\- ,]");

if(!regEx.test(xfa.event.change)){

xfa.event.change = "";

  }

Thank you for any help!

1 Reply

Avatar

Level 8

Add \\* into your regular expression between the brackets ([]). Also, remove any spaces in your regular expression.

Kyle