Forum Moderators: open

Message Too Old, No Replies

Onsubmit not cancelling action?

Please help...

         

walker

3:26 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



Hi

The validate onsubmit script below seems to react with the alert box but is not cancelling the action. I can't for the life of me figure out why - I have done numorous other similar scrips. Any help would really be apreaciated.

<HTML>
<HEAD>

<SCRIPT>
//VALIDATE FORM EMAIL

function CheckRequest() {

if(document.RequestReportForm.dest.value.length == 0) {
document.RequestReportForm.dest.focus();
alert("TYPE TEXT MESSAGE HERE");
return false;
}

document.forms[0].submit()
return true;
}

</SCRIPT>

<form name="RequestReportForm" ONSUBMIT="CheckRequest()" action="test.dll" METHOD="POST" >

<INPUT TYPE=submit VALUE="Request Report " class=button">
<input type=text name='dest' style="width=200" size="20" >

</FORM>
</body>
</html>

CaseyRyan

4:33 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



in your form tag, change the onSubmit event to:

ONSUBMIT="return CheckRequest()"

That should fix that.

You could also remove the document.forms[0].submit() from your CheckRequest function because returning the true will cause the form to submit.

-=casey=-

walker

4:48 pm on Mar 15, 2005 (gmt 0)

10+ Year Member



Thanx, cant believe I didnt see my mistake!

Kind Regards

Rod