how do I cancell a form submit in netscape or opera?
How do I cancell a form submit in java script for netscape and Opera?
The following works for ie only.
function validate()
{
window.alert("your form won't be submitted")
window.event.returnValue=false
}
<form name="form1" method="post" action="page.asp" onsubmit="validate()">
Andy Kohlenberg
Jerusalem, Israel
akohl posted this at 14:45 — 16th January 2002.
They have: 117 posts
Joined: Feb 2001
sorry. Should have put this into client side scripting.
Awaiting thread move!
Peter J. Boettcher posted this at 15:06 — 17th January 2002.
They have: 812 posts
Joined: Feb 2000
Just use a return, for example:
function validate()
{
// some validation code here
if (validation == "ok") {
//submit form
return true;
}
else {
window.alert("your form won't be submitted")
return false;
}
}
<form name="form1" method="post" action="page.asp" onsubmit="return validate()">
I just used "validation == "ok" to point out that the code would only enter there if it passed validation. You would have to put your own logic in there. I don't know if this will work in Opera, but I don't see why it shouldn't.
PJ | Are we there yet?
pjboettcher.com
akohl posted this at 14:06 — 18th January 2002.
They have: 117 posts
Joined: Feb 2001
That works fine in both. Thanks!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.