Ho questo codice nel file esterno
codice:
function xxx1(){
var f = document.mioform1;
var parole = new RegExp("(mel(a|e)|per(a|e))");
var stringhe = ["nome","suoemail","citta","messaggio"];
for (i=0; i<stringhe.length; i++){
var campo = eval(f+"." + stringhe[i]);
if(campo.value.match(parole) && campo.value.match(parole)[0]){
campo.style.backgroundColor='red'
campo.style.color='white'
alert("La parola '"+campo.value.match(parole)[0]+"' non è ammessa");
campo.focus();
campo.style.color=''
return false;
}
}
return true;
}
che richiamo nel form cosi:
codice:
<form...onsubmit="return xxx1() ">
Quando lo testo da errore "object" non è definito
su questa riga if(campo.value.match(parole) && campo.value.match(parole)[0]){
...ma non c'è quella parola (object)!!
VVoVe: