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!

form validation

Status
Not open for further replies.

prasoon

Programmer
Nov 15, 2002
67
IN
I am having three submit buttons in my form one display, one delete, and other one is add.

and i want to validate the field 1 in the form before clicking
on delete or add button.

other condition is if all the fileds in the form are blank and i click on display button then it should show me all the records form the DB, which is working fine.
also for the same button when i type any of the fields on the form it should show me details regarding that thing only.

how can i put the form validations satisfyng all the conditions?

pls help
 

have a look at this. ask again if you don't understand something

Code:
<script>
function validateForm(){
if((document.getElementById('hdn')).value=='1') alert('button 1 pressed');
else if((document.getElementById('hdn')).value=='2') alert('button 2 pressed');
else if((document.getElementById('hdn')).value=='3') alert('button 3 pressed');
}
</script>


<form action='myAction.asp' method='post' onSubmit='validateForm();'>
<input type='text' id='field1' name='field1'>
<input type='hidden' id='hdn' name='hdn' value='0'>
<input type='submit' id='btn1' value='button 1' onClick='hdn.value="1"'>
<input type='submit' id='btn2' value='button 2' onClick='hdn.value="2"'>
<input type='submit' id='btn3' value='button 3' onClick='hdn.value="3"'>
</form>

N
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top