I would like to replace special characters from the user input with other characters.
Currently, I have the following which does not work. Any help would be appreciated.
$(document).ready(function(){
$("#text_box_id").change(function () {
/*var name = $(this).val();
var dname_without_space = $("#text_box_id").val().replace(/ /g, "");*/
var specialCharList = ["Á","É","Í","Ó","Ú","á","é","í","ó","ú","ñ","Ñ"];
var replaceChar = ["A","E","I","O","U","a","e","i","o","u","n","N"];
var inputUser = $("#text_box_id").val();
var splitInput = inputUser.split(" ");
console.log(splitInput);
for(var i = 0; i < inputUser.length; i++){
for(var x = 0; x < specialCharList.length; x++){
if(splitInput[i] == specialCharList[x]){
splitInput[i] = replaceChar[x];
}
}
}
var modInputUser = splitInput.join(" ");
console.log(modInputUser);
/*var name_without_special_char = $("#text_box_id").val().replace(/[^a-zA-Z 0-9]+/g, "");
$(this).val(name_without_special_char);
console.log(name_without_special_char)*/
});
});