Click to See Complete Forum and Search --> : Unwanted page refresh


alex_harmes
01-12-2004, 10:17 AM
Can anyone see why this code is refreshing the page? I have used validation code often but for some reason this reloads the page and clears all fields - not the action I want!

function filIn() {
var form = document.forms[0];
var str = form.fname.value;
var str1 = form.lname.value;
var str2 = form.vismail.value;
var str3 = form.add1.value;
var str4 = form.city.value;
var str5 = form.postcode.value;
if (str == "" || str1 == "" || str2 == "" || str3 == "" || str4 == "" || str5 == "" ) {
alert("you have not fill in ALL required field.");
return false;
} else {
sendInfo();
}
}

function sendInfo() {
var page = "";
page = "send_info.asp";
window.location.href = page
}

Thanks in advance for any help.

Alex

Pittimann
01-12-2004, 10:29 AM
Hi!

Due to the fact that you didn't post the code of your form, this is not more than an assumption:

You call filIn() onsubmit but you didn't put the return there:

<form onsubmit="return filIn()">

Cheers - Pit

alex_harmes
01-12-2004, 10:33 AM
Thanks for that! But alas! Now it is not going to the send_info page upon completion!!

Arrrgh!

Alex (working to deadline!)

Pittimann
01-12-2004, 10:56 AM
Hi!

Please change your form tag to something like:

<form action="send_info.asp" onsubmit="return filIn()">

and instead of the line: sendInfo();
use: return true;

Cheers - Pit