I want to avoid the use of special characters (like: "," or "()") in a specific Field

Sven Heide
Tera Contributor

Hi there! 🙂 

 

I want to avoid the use of special characters in a specific Field...

 

what is the best way to achieve this?

 

My Business Users are using Characters like "," or "()" in a specfic Field, which will produce a nightmare in my exports, If I receive requests for exporting Data via Querybuilder or Reports...

 

What is the best way to force my Business Users to not use these Characters in a specfic field?

 

I want to avoid my Business Users that they can use these characters in future entries in a specific Table

 

Thank you very much for every advise!

 

Kind Regards

 

Sven

 

 

6 REPLIES 6

Ratnakar7
Mega Sage
Mega Sage

Hi @Sven Heide ,

 

You can write onChange- Client script with a regular expression to disallow special characters (like: "," or "()").

 

var specials=/,()/;

var name = g_form.getValue('<field_name>');
if (specials.test(name)){
g_form.addErrorMessage("Sepecial Characters "," & "()" are allowed");
g_form.setValue('<field_name'','');
}

 

Regards,

Ratnakar

Basheer
Mega Sage

Hi @Sven Heide ,

Whichever BR you are triggering 

fetch the value for example special characters are in description

 

var description = current.description;

if(description.includes(",") || description.includes("()")){

gs.addInfoMessage("Please do not enter special characters");

retun false;

}

else{

//do your scripting

}

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

If you want to do it on client script then you can do it on submit - client scripts if you want during save or submit or if you want it on a particular field then go for on change client script

var description= g_form.getValue("column_name")

if(description.includes(",") || description.includes("()")){

gs.addInfoMessage("Please do not enter special characters");

retun false;

}

else{

//do your scripting

}

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

kalyan13
Tera Guru

Hi @Sven Heide ,

The below code will work for all special characters not only for ", ()". Because as of now there are using these two characters in future if they might use other character as well. So, i think below code will helps you to stop from all special characters   

var regex = new RegExp("^[a-zA-Z0-9]*$"); //no special characters
if(!regex.test(newValue)){

g_form.addErrorMessage('Please Don't enter any special character');
g_form.setValue('<field_name>', ''); // if you want to make field as blank if any special character founds then  you can add this line 
}

If it works Please mark my response as Correct / Helpful

Regards,
Kalyan