remove from onsubmit="return jvsValidate() ;" in form tag and update syntax with button like below
<asp:button id="btnRoute" runat="server" text="Save" OnClientClick="return jvsValidate();" ></asp:button>
Question
Since upgrading from .NET 1.1 to 4.0 I have a problem with a form.
The form has some dropdowns with AutoPostBack=true because they have some SelectedIndexChanged handlers that need to fire to populate other dropdowns, etc.
But now, when a new value is selected in the dropdown, it fires the onSubmit script specified in the form tag:
<form id="Form1" method="post" runat="server" onsubmit="return jvsValidate() ;">
Where before, that would only fire when the button control was clicked:
<asp:button id="btnRoute" runat="server" text="Save"></asp:button>
What's the best way to rectify this?
Solution
remove from onsubmit="return jvsValidate() ;" in form tag and update syntax with button like below
<asp:button id="btnRoute" runat="server" text="Save" OnClientClick="return jvsValidate();" ></asp:button>
OTHER TIPS
Seems like the easiest workaround would be to attach jvsValidate()
to the btnRoute
click event, rather than the form's submit event. Just add some Javascript to the effect document.getElementById('btnRoute').click = jsValidate;
, and remove the onsubmit
attribute from the form.