Forum Moderators: open

Message Too Old, No Replies

Javascript - Return False (Page still submitting)

         

sswift

8:12 pm on Sep 25, 2003 (gmt 0)

10+ Year Member



Hey everyone, I have a unique problem in c#.

I have an asp button and in the page_load, I call,

btnOK.attributes.add("onClick", "return myfunction();");

Here's the myfunction:

void myfunction()
{
if (confirm("Are you sure")) return true;
else return false;
}

For some reason, my page is now submitting even though I'm returning false. I've even commented out all of the code and have only had the statement "return false;" and the page still submits. This used to work, but now it doesn't.

Has anyone else experienced this?

I you have any help, please email me at <sorry, no email addresses>.

Thanks!

[edited by: tedster at 8:39 pm (utc) on Sep. 25, 2003]

MonkeeSage

3:30 am on Sep 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a guess, and not tested...may not help at all...but you could try adding an onsubmit handler to the form and return false from there to cancel the submit event propigation if certain conditions aren't met....

Jordan

BlobFisk

11:26 am on Sep 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, sswift!


void myfunction()
{
if (confirm("Are you sure")) return true;
else return false;
}

Try this:


myfunction() {
if (confirm("Are you sure")) {
return true;
}
else {
return false;
}
}