-6

I have an email contact form linked to a php script which is working, but I want to check if the fields are empty, if so, the text input container will change the background color.

this is part of the html code:

<!--START CONTACT FORM CONTAINER -->
<div id="form_container">

<form name="contact_form" method="post" action="php_script/email.php">
<div class="contact">
<form action="" method="get"></form>
<label>First Name</label>
<input name="first_name" type="text"/>

<form action="" method="get"></form>
<label>Last Name</label>
<input name="last_name" type="text"/>

<form action="" method="get"></form>
<label>Email Address</label>
<input name="email_address" type="text"/>

<label>Comment</label>
<textarea name="comments" cols="" rows=""></textarea>

<input type="submit" value="Submit"/>

<input type="reset" value="Reset"/>
</div>
</form>
</div>

how can I call a javascript from ?

SomeShinyObject
  • 7,581
  • 6
  • 39
  • 59
user2520212
  • 121
  • 1
  • 1
  • 9

1 Answers1

0

Use the OnSubmit method of the form tag:

<FORM OnSubmit="somemethod()">

Return false to hinder submission.

carny666
  • 2,325
  • 2
  • 18
  • 27
  • Why was this downvoted? It is the simplest possible answer (AFAIK), but it works. +1. – 11684 Jun 25 '13 at 13:56
  • I guess we get penalized for answering simple questions with simple answers rather than giving the op shit for not googling.. go figure. – carny666 Jun 26 '13 at 14:12