Click to See Complete Forum and Search --> : Simple question


slam2004
12-15-2003, 09:18 AM
Hi, thanks for reading...

I have made a form on the contact page, when I hit the submit button to validate the form, if validation is ok, how do i get the browser to go back automatically to the main page?

Cheers
James

clairec666
12-15-2003, 09:22 AM
<form onsubmit="function1()">
<script type="text/javascript">
function function1() {
if(validation==true) { // test so see whether info is valid
window.location.href="";
}
</script>

slam2004
12-15-2003, 09:43 AM
Thanks, I already have a funtion, how do I change it to accomodate your bit of code:

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkFields() {
missinginfo = "";
if (document.form.realname.value == "") {
missinginfo += "\n - Name";
}
if ((document.form.email.value == "") ||
(document.form.email.value.indexOf('@') == -1) ||
(document.form.email.value.indexOf('.') == -1)) {
missinginfo += "\n - Email address";
}
if (missinginfo != "") {
missinginfo =
"Invalid entry in the following fileds:\n" +
missinginfo +
"\n\nPlease re-enter and submit again!"
alert(missinginfo);
return false;
}
else return true;

}
// End -->
</script>

clairec666
12-15-2003, 09:46 AM
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkFields() {
missinginfo = "";
if (document.form.realname.value == "") {
missinginfo += "\n - Name";
}
if ((document.form.email.value == "") ||
(document.form.email.value.indexOf('@') == -1) ||
(document.form.email.value.indexOf('.') == -1)) {
missinginfo += "\n - Email address";
}
if (missinginfo != "") {
missinginfo =
"Invalid entry in the following fileds:\n" +
missinginfo +
"\n\nPlease re-enter and submit again!"
alert(missinginfo);
return false;
}
else load_next_page();
}

function load_next_page() {
window.loaction.href="next_page.html";
}
// End -->
</script>

Hope this is okay! :D

slam2004
12-15-2003, 10:26 AM
Hi

Doesn't seem to be working, copied and pasted it straigiht from your post, any ideas why its not working?