Originariamente inviato da fcaldera
sbaglio o ieri su
questa discussione avevi detto che non partiva nemmeno il submit?
secondo me hai qualche problema nella routine di validazione...
C'è solo il tuo codice che non va, voglio farti vedere i controlli magari qualcosa non va però va sempre tutto
Ora nel form è cosi:
<input type="submit" name="bottone1" value="Invia" onclick="this.disabled=true" />
Nel file esterno:
codice:
//Chiude automaticamente finestre popup "Scrivimi e Segnala il sito ai tuoi amici"
function aprisegnala(){
var chiudiFinestra=window.close();
}
function closePopup(){
var xxx=window.setTimeout('aprisegnala()',3000);
}
function controlla1(){
var f = document.mioform1;
//.value == "" rende il campo obbligatorio
//.charAt(0) == " " non permette la barra spaziatrice come primo carattere
if(f.nome.value == "" || f.nome.value.charAt(0) == " "){
f.nome.style.backgroundColor='#e2e2e2'
alert("Inserire il Nome");
f.nome.focus();
return false;
}
if((f.nome.value.indexOf("<") != -1) || (f.nome.value.indexOf(">") != -1) || (f.nome.value.indexOf("\\") != -1)){
alert("I caratteri < > \\ non sono ammessi");
f.nome.focus();
return false;
}
if(f.suoemail.value == "" || f.suoemail.value.charAt(0) == " "){
f.suoemail.style.backgroundColor='#e2e2e2'
alert("Inserire l'Email");
f.suoemail.focus();
return false;
}
//Valida l'Email
//valida pippo@email.{2,4}//pip.po@email.{2,4}//pip_po@email.{2,4}//pip-po@email.{2,4}
var reg = new RegExp("^([-_.#$&a-z0-9]+)[@][a-z]+(\\.[a-z]{2,4})(\\.[a-z]{2,4})?$","");
if (!f.suoemail.value.match(reg)){
f.suoemail.style.backgroundColor='#e2e2e2'
alert("Inserire un' Email valida");
f.suoemail.focus();
return false;
}
if((f.citta.value.indexOf("<") != -1) || (f.citta.value.indexOf(">") != -1) || (f.citta.value.indexOf("\\") != -1)){
alert("I caratteri < > \\ non sono ammessi");
f.citta.focus();
return false;
}
if(f.messaggio.value == "" || f.messaggio.value.charAt(0) == " "){
f.messaggio.style.backgroundColor='#e2e2e2'
alert("Inserire il Messaggio");
f.messaggio.focus();
return false;
}
if((f.messaggio.value.indexOf("<") != -1) || (f.messaggio.value.indexOf(">") != -1) || (f.messaggio.value.indexOf("\\") != -1)){
alert("I caratteri < > \\ non sono ammessi");
f.messaggio.focus();
return false;
}
return true;
}
//Non lascia spazi vuoti (per Segnala sito e Scrivimi)
function ignoreSpaces(string){
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}
//Caratteri max inseribili
function conta(val){
max=500
if (val.messaggio.value.length > max){
val.messaggio.value = val.messaggio.value.substring(0,max)
rest = 0
}
else{
rest = max - val.messaggio.value.length
}
val.num.value = rest
}
//Script che colora il campo obbligatorio non compilato (per Segnala sito e Scrivimi)
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
//Quando si digita nel campo giallo dopo l'alert, fa tornare il campo bianco (per Segnala sito e Scrivimi)
var highlightcolor="white"
var ns6=document.getElementById&&!document.all
var previous=''
var eventobj
//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/
//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}