I have a question, I have defined a function to restrict offensive words in my input but I need a code so that regardless of the word that is entered, the code restricts the words in both female and male, example: dog - bitch
the following is my code in javascript:
var malasPalabras = ['perro'];
const checkMalasPalabras = (palabra) => {
var rgx = new RegExp(malasPalabras.join("|")+"|" + "/gi");
return (rgx.test(palabra));
}
$('#boton-guardar').click(() => {
var nombre = $("#nombretxt").val().toLowerCase();
if(checkMalasPalabras(nombre) == true){
swal("Ups! algo ha ocurrido", "Ingresaste una palabra indebida, intenta de nuevo", "error");
document.getElementById("nombretxt").value = "";
}