Can someone help? I have a form that uses a javascript that validates each field when the submit button is clicked. The form does not close after being submitted. Can some code by added to the submit button. I would like the form to close automatically after the submit button is clicked but I don't know how. I also need a java script to add a cookie to their computer so the form does not come up after they have submitted it. Can that all be accomplished with one script? This is what I am using now. I got it at javascript.internet.com I can dump it if there is something better to use.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea") &&
tempobj.value=='')||(tempobj.type.toString().charA t(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUppe rCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return true;
}
// End -->
</script>
Then in the form tags I'm using:
<form onSubmit="return checkrequired(this)" onSubmit="return submitForm()" action="mailto:myaddress@xxxx.com?subject=My Subject" name="My Form" method="post" enctype="text/plain">