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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Diverting the Submit 1

Status
Not open for further replies.

scohan

Programmer
Dec 29, 2000
283
US
Is there a way to stop the submittal of the form to the server, because, for example, a field is not filled out? I'd like to be able to use an onclick event to the submit control and if a field is empty, pop-up an alert, but don't submit the form. Thanks.
 
<script>

function checkForm(){
if (document.myForm.myField.value == &quot;&quot;){
alert(&quot;blank field&quot;)
return false
}
return true
}

<form action=&quot;someAct.asp&quot; onSubmit=&quot;return checkForm()&quot; name=&quot;myForm&quot;>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top