Thursday, March 29, 2012

onsubmit Event in aspx page.

Hi,
I'm trying to do some client side validation before sumbitting a form. I
added an onclick attribute to the submit button (<asp:Button> control) and
the source of the page looks ok on the client. In the function that is calle
d
by the onclick I do window.event.cancelBubble = true;
hoping that this will stop submitting the form, but the form is still
submitted (I'm assuming that onclick event is fired before the onsumbit
event).
Is it possible to cancel the submition of the form?
Thank you"Vi" <Vi@.discussions.microsoft.com> wrote in message
news:92A6FBE7-B7B1-4EF5-B12F-E5C4AC8535AB@.microsoft.com...

> Is it possible to cancel the submition of the form?
<script>
function validateForm()
{
if (<some validation check> == false)
{
return false;
}
else
{
document.forms[0].submit();
}
}
</script>

0 comments:

Post a Comment