Problem : Stop an "Unonlaod" when then confirmation is false.
Is a really good script but i have just one problem. The problem that i have is when i click on a link. The scipt ask "Do you want to save DATA". When you click "Yes" and the name form is empty. The script tell you a message, but i go to another page. ALL I WANT IS TO BLOCK IT, AND STAY IN THE SAME PAGE WITHOUT RELOADING. LIKE WHEN YOU CLICK SUBMIT.
Can some one help me ?
Is a good script but i have only one problem ?
donald.loignon@cgocable.ca
Here is the script
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onunload="CloseWindowSauvegarde()">
<p>
<SCRIPT LANGUAGE="JavaScript">
function CloseWindowSauvegarde ()
{
var answer = confirm ("DO YOU WANT TO SAVE DATA")
if (answer)
{
return FrontPage_Form1_Validator(formulaire);
}
else
{
alert ("LOST YOUR DATA");
}
}
// *********** VALIDATION
function FrontPage_Form1_Validator(theForm)
{
if ((theForm.Nom.value.length < 1) || (theForm.Nom.length > 225))
{
alert("NAME must contain NAME OF the COMPANY must contain between 1 and 225 characters. ");
theForm.Nom.focus();
return (false);
}
return (true);
document.formulaire.submit ();
}
</script>
</p>
<p><a href="http://www.google.ca">Change lick with save</a></p>
<form name="formulaire" method="post" action="s-compagnie.asp" onsubmit="return FrontPage_Form1_Validator(this)">
Name :
<input name="Nom" type="text" id="Nom">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>