You can do this, although it seems like more instrusive.
Alternative way is asking whether the user wants to exit.
<script>
function checkComplete()
{
if (document.myform.myName.va
{
alert("Please complete the form!")
return false;
}
else
{
return true;
}
}
</script>
<html>
<body onunload="checkform()">
<form name="myform" onsubmit="return checkComplete()">
My Name: <input type="text" name="myName" size="50"><br>
<input type="Submit" value="Send Form" name="Submit">
</form>
</body>
</html>
Main Topics
Browse All Topics





by: ZvonkoPosted on 2006-09-05 at 12:44:00ID: 17458421
Check this:
<html>
<head>
<title>Zvonko *</title>
<script>
var warn = true;
</script>
</head>
<body onBeforeUnload="if(warn) return 'Not submited form data.\nIf you press OK you loose your form data'">
<form onSubmit="warn=false;">
<input type="text" name="myField">
<input type="submit">
</form>
</body>
</html>