Good to see if you can help me I need a function that when writing characters in an input = text checks if prohibited characters are being written that are in a constant, apart from not writing them, it would have to return a true or false depending on whether it is or not typing those characters.
const forbiddenChars = '_`#*¿?=.,;-±ªº®%/$@~{}()[]<>/\\"|';
I currently have this that removes the prohibited characters but I can't check if you can help me.
removeForbidden (searchString) {
const forbiddenChars = '_`#*¿?=.,;-±ªº®%/$@~{}()[]<>/\\"|';
let myval = searchString;
for (var i = 0; i < forbiddenChars.length; i++) {
myval = myval.replace(forbiddenChars[i], '');
};
return myval;
}
Having the method that you already have, you can modify it a bit so that it checks if the special character is there. If so, return a
false
for that use the includes function
You can also use regular expressions to see if it contains any of those characters