Ciao a tutti. Ho una pagina PHP con 2 form che appaiono a seconda del tipo di pagamento scelto , vorrei validare i campi e a seconda del pagamento rimanere sulla stessa pagina o fare un redirect su un altra pagina. Il mio codice sembre funzionare ma quando deve fare il redirect su un'altra pagina non fa nulla e rimane sulla stessa pagina
<script language="javascript">
function valform(thisform){
var selObj = document.getElementById("signup_payment_type");
var selIndex = selObj.selectedIndex;
var vals=selObj.options[selIndex].value;
//SE IL TIPO PAGAMENTO E' DIVERSO DA CHEQUE CONTROLLA TUTTI I CAMPI E RIMANE SULLA STESSA PAGINA
if(vals!="Cheque"){
if(trimString(thisform.cfname.value)==""){
alert("Please enter first name");
thisform.cfname.focus();
return false;
}
if(trimString(thisform.clname.value)==""){
alert("Please enter last name");
thisform.clname.focus();
return false;
}
if(trimString(thisform.clientcreditcard.value)=="" ){
alert("Please enter your Credit Card No");
thisform.clientcreditcard.focus();
return false;
}
if(Mod10(thisform.clientcreditcard.value)==false){
alert("This is NOT a valid Credit Card Number!");
thisform.clientcreditcard.focus();
return false;
}
if(trimString(thisform.expmonth.value)==""){
alert("Select expiry month");
thisform.expmonth.focus();
return false;
}
if(trimString(thisform.expyear.value)==""){
alert("Select expiry year");
thisform.expyear.focus();
return false;
}
if(trimString(thisform.ccv2.value)==""){
alert("Please enter Credit Card security code");
thisform.ccv2.focus();
return false;
}
if(thisform.agreeCards.checked==false)
{
alert("Please accept the terms and conditions");
return false;
}
return true;
//SE PAGAMENTO == A CHEQUE CONTROLLA UN SOLO CAMPO E REDIRECTY SU UN'ALTRA PAGINA
}else if(vals=="Cheque")
{
if(Chequeform.agreeCheque.checked==false)
{
alert("Please accept the terms and conditions");
return false;
}else
{
//QUI NON VA
window.location="http://www.miosito.com";
}
}
}
Grazie a tutti