PDA

View Full Version : Thank You-page AFTER Form validation is OK


Roentje
01-28-2003, 09:07 AM
Hey there, hope anyone can help me with this:
Made a form that I want to validate on SUBMIT. That's no problem so far. I also have a THANK YOU-page that people see after sending the form.
BUT: Now people see the THANK YOU-page when they click OK at the Alertmessage that appears when they forget to fill in a field in the form. That shouldn't happen, ofcourse.
Does anyone know how to prevent this and to return people to the filled in form to fill in the missing field?
JSUT TO BE SURE: I want people to see the THANK YOU-page when they have filled in the form properly.

THANX for your help!!!

J!

scoutt
01-28-2003, 09:29 AM
some code would be nice....

Roentje
01-28-2003, 09:38 AM
SORRY, here's the parts that's it about:

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' mag alleen een e-mail-adres bevatten.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' mag alleen nummers bevatten.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is niet ingevuld.\n'; }
} if (errors) alert('De volgende gegevens zijn niet (juist) ingevuld:\n'+errors);
document.MM_returnValue = (errors == '');
}

function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>

AT THE BOTTOM IT IS:

<td colspan="2"><input name="Submit" type="submit" onClick="MM_validateForm('naam','','R','straat','','R','Nummer','','R','postcode','','R','woonplaats','','R', 'telefoonnummer','','R','faxnummer','','NisNum','email_adres','','RisEmail');MM_goToURL('parent.fram es[\'contentFrame\']','bedankt.html');return document.MM_returnValue" value="Verzend mijn gegevens"></td>

DOES THIS TELL YOU ENOUGH?

scoutt
01-28-2003, 10:13 AM
well I see you are using dreamweaver functions.. very limited in that dept.

also I would put the onclick in the form tag itself and change it to onSubmit. and take the MM_goToURL out of the onclick as well. you want it in the MM_validateForm function anyway.

I will move this to the client side foum as you might get a better response there.

Roentje
01-28-2003, 10:21 AM
THANX so far, Scoutt