I use the script below to replace some diacritical marks from legacy to standard form. Works fine in all browsers, except Firefox; where it does not work at all. I assume the problem is from event.target, but I am just beginning with javascript and lack the know how for fixing this.
Found this (posible?) solution to my problem, but don't know how to adapt it for my script: event.target not working on Firefox
Any help would be greatly appreciated!
function inlocuire_diacritice (form) {
var form = event.target;
var i, l;
for (i = 0, l = form.elements.length; i < l; i += 1) {
if (form.elements[i].type === 'text') {
form.elements[i].value = form.elements[i].value.replace(/Ş/g, 'Ș');
form.elements[i].value = form.elements[i].value.replace(/ş/g, 'ș');
form.elements[i].value = form.elements[i].value.replace(/Ţ/g, 'Ț');
form.elements[i].value = form.elements[i].value.replace(/ţ/g, 'ț');
}
}
return true;
}
EDIT: I call the function from inside another function:
function validate(form) {
//form validation script
inlocuire_diacritice (form);
}
And this is called on form submit:
<form action="whatever" name="whatever" method="post" onsubmit="return validate(this)">