
December 12th, 2000, 07:03 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
<i><b>Originally posted by : Andrew Taylor (andrew.taylor@analysys.com)</b></i><br />I think the best way to do this is with the<br />onSubmit event: this also copes with the case<br />where the form is submitted by the user<br />presing Enter instead of clicking on a <br />button. Roughly speaking you do it like this:<br /><br />for the <form> tag:<br /><Form name="myForm" action="whatever.asp" onSubmit="return checkSubmit()"><br /><br />in <Script><br />Function checkSubmit()<br />{<br /> if (confirm ("Do you really want to submit?"))<br /> return true;<br /> else<br /> return false;<br />}<br /><br />or you can abbreviate the code to<br />return confirm ("Do you really want to submit?")<br /><br />You can also use this technique to validate the<br />data in the form..<br /><br />if (...data invalid...)<br />{<br /> alert ("Please correct errors...");<br /> return false;<br />}<br /><br /><br />HTH<br />Andrew<br /><br /><br /><br /><br />------------<br />Zed at 10/24/2000 6:26:32 AM<br /><br />Hi guys,<br /><br /> I have a runat="server" form. When I click on the submit form. I want to call some client side JavaScript to pop up a confirmation message box. Then I want the JavaScript code to submit the form back to ASP+. How can it be done?<br /><br />Thanks.<br /><br /><script language="JavaScript"><br /> function PromptConfirm()<br /> {<br /> if (confirm('Are you sure?') == true)<br /> {<br /> //This part is probably wrong, but you get the idea.<br /> document.form.submit()<br /> }<br /> return<br /> }<br /></script><br /><br /><form runat="server"><br />...<br /><br /><Input Type="Button" Value="Submit" onclick="PromptConfirm"><br /><br /></form>
|