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

Another Form question 1

Status
Not open for further replies.

edgarv

MIS
Jul 25, 2003
248
US
hello,

I am still learning html and some other scriptiong languages. I have a form, what I want to do is that when people fill the form they have to fill all the fields, otherwise it will not submit the form untill all the fields are filled out, how can I acomplish this?

thank you
 
Code:
<script type="text/javascript">
function formEval(form) {
if ( (form.name.value == "") ||
     (form.email.value == "") ||
     (form.subject.value == "") ||
     (form.text.value == "") ) {
   alert("Please enter required fields.\nThank You!");
   return false;
   }
}
</script
<form name="mail" onSubmit="return formEval(this)" method="post"
 enctype="multipart/form-data" action="next.htm"><table>
<tr><td>To: </td><td><b>Company Name</b></td></tr>
<tr><td>From: </td>
<td><input name="name" type="text" size="36" /></td></tr>
<tr><td>E-Mail: </td>
<td><input name="email" type="text" size="36" /></td></tr>
<tr><td>Subject: </td>
<td><input name="subject" type="text" size="36" /></td></tr>
<tr><td valign="top">Message: </td>
<td><textarea name="text" rows="10" cols="54"></textarea></td></tr>
<tr><td>&nbsp;</td><td><input value="Send" type="submit" /></td></tr>
</table></form>

Clive
 
thank you so very very much I really appreciate it
 
Unless of course javascript is disabled. But you may not wish to worry about that. I don't think it's as common as some would have you believe, but there are certainly users that don't have javascript turned on.

If this may be an issue to you then you would need to use a server side solution such as PHP, ASP or ColdFusion.


Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top