We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Anyone help? :); Form validation
Topic Started: Feb 1 2007, 07:15 PM (235 Views)
Lulubrfc
Member
[ * ]
Quote:
 
<html>
<!-- Created on: 01/02/2007 -->
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <title>Example Online Airline Booking System</title>
  <HTML>
<HEAD>     

<h1> Airways Limited Booking System</h1>
<SCRIPT LANGUAGE="JavaScript">
function validate(myform)

{
if (myform.fname.value=="0") {
alert;{"Please enter your first name"};
myform.fname.focus();
return false;
}
return true

}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="myform"> 
Title: <br>
<select name="title">
<option selected>Please select
<option>Mr
<option>Mrs
<option>Miss
<option>Ms.
<option>Dr
<option>Other
</select>
<br>

  First Name
      <INPUT TYPE="text" NAME="fname"><p>
 
   
    Last Name
      <INPUT TYPE="text" NAME="lname"><p>
   
 
  Flight Departure 
      <INPUT TYPE="text" NAME="depart"><p>
 
 
    Flight Destination
      <INPUT TYPE="text" NAME="dest"><p>
 
   
  Date of travel
      <INPUT TYPE="text" NAME="date"><p>
 
     
  Flight Seating Class:
      <select name="class"> 
 
<option selected>Please select
<option>1
<option>2
<option>3

</select>
<br>

 
      <INPUT TYPE="button" VALUE="Reset" onClick="doit()">
  <INPUT TYPE="button" VALUE="Submit" onClick="doit()">
</FORM>
</BODY>
</HTML>

 
</head>
<body>

</body>
</html>



I can't seem to get my validation working? - I am doing something wrong..if i could fix that one, I'm sure I could get it working for the others?? :$

Thanks.. :)

Offline Profile Quote Post Goto Top
 
Dennis
Member Avatar
Member
[ *  *  *  *  *  *  * ]
1. There is no function called doit(). Do you mean to put validate()?
2. Remove the parameter from the validate() variable. It's unnecessary.
3. Change

Code:
 
if (myform.fname.value=="0") {


to

Code:
 
if (document.myform.fname.value=="0") {


I'm no Javascript expert, so if I messed up, anyone feel free to correct me.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply