Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

aborting sending incomplete form

Status
Not open for further replies.

olivia

Programmer
Apr 10, 2000
8
US
Hi, <br>Anyone know how to abort a post operation if the form data is incomplete? do you not specify the action in the form tag but put it in the script to be sent if it passes the validation?? Any ideas gratefully received. thanks!!<br><br>this is what I'm thinking but it doesn't work. <br><FONT FACE=monospace><br>function checkcurrent() {<br> if (form.Patient_ID.value == &quot;&quot; ¦¦ form.Hospital.value == &quot;&quot;) {<br> alert(&quot;Please enter both the patient ID and the hospital&quot;)<br>}else{ <br>(form.action == &quot;send to cgi&quot;)<br> }<br> }<br></font>
 
I'm very new to JavaScript, but can't you try returning it false?<br><br>function checkcurrent() {<br>if (form.Patient_ID.value == &quot;&quot; ?? form.Hospital.value == &quot;&quot;) {<br>alert(&quot;Please enter both the patient ID and the hospital&quot;);<br>return false;<br>}else{ <br>(form.action == &quot;send to cgi&quot;)<br>}<br>}
 
In your form tag, specify an onSubmit handler:<br>&lt;FORM action=&quot;MyCgiPage&quot; method=&quot;post&quot; onSubmit=&quot;return checkcurrent()&quot;&gt;<br><br>if the return value from checkcurrent() is true, the form will be submitted. If false,&nbsp;&nbsp;it won't. <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top