Restrict Special Characters

rambabu1
Giga Expert

Hi 

I want to restrict special character / \during creation of use id in user form.

Please help if you have any idea.

7 REPLIES 7

Priyanka Teke1
Mega Sage

Hello,

You can create onchange client script 

 

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

          return;

    }

 

    var specialChar = /[~@|$&^<>\*+=;?`'())[\]]/;

  if(specialChar.test(newValue)){

  alert('special characters not allowed');

g_form.setValue('Field','');

  }

}

But i want to use those 2 special characters only.

how i can use those 2 characters?                   

Hi, you mention that "restrict special character / \during creation of use id in user form.".

which special character is allowed in your case, including a-z,A-Z and 0-9. 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Priyanka Teke1
Mega Sage

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

          return;

    }

 

    var specialChar = /\;

  if(specialChar.test(newValue)){

  alert('special characters not allowed');

g_form.setValue('Field','');

  }

}