Hello,
Can someone please help.
I have few hundreds of words to be avoided being entered in the free text field while user answering the survey.
Only option I see is to add one condition for each word.
Can someone help with the java script code if its possible.
Solved
Custom validation to avoid certain word in free text field.
Best answer by cbhavsar
Hi,
Here is the script you are looking for. Try modifying it based on your requirement.
var substrings = ["Monday", "Tuesday", "Wednesday"];
var str;
str = "Hey, today is Monday!";
if (new RegExp(substrings.join("|")).test(str)) {
console.log("Text have a word from array!");
} else {
console.log("Text don't have any word from array!");
}
All the very best for your project!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
