Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Validating Forms

    I need help validating my form, it looks like that my function isnt working when the submit button is clicked...and is there any way that you can include validating radio buttons and Selection menus as well.. ALSO when you hit submit it does go to a completion page that posts the inputs...
    ----------------
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang = "en" dir="ltr">
    <head>
    <title>Conference Registration</title>
    <style type="text/css">
    body {background-color:silver; color:white}
    h1 {color:black;}
    h3 {color:gray;}
    h2 {color:gray;}
    i {color:black;}
    </style>
    <script type="text/javascript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS
    /*
    Polack
    midterm, 2005
    ECA225
    */
    function submitForm(){
    if (document.form[0].name_First_Name.value == ""
    || document.form[0].name_Last_Name.value == ""
    || document.form[0].name_Street_Address.value == ""
    || document.form[0].name_City.value == ""
    || document.form[0].name_State.value == ""
    || document.form[0].name_Zip.value == ""
    || document.form[0].name_Phone_Number.value == ""
    || document.form[0].name_Fax.value == ""){
    window.alart("You must enter your Name and Address Information.");
    return false;
    }
    else if(document.form[0].name_Credit_Card.value == ""
    window.alart("You must enter your Credit Card Information.");
    return false;
    }
    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </script>
    </head>
    <body>
    <form action="FormProcessor.html" Method="get">
    <h1> Conference Registration</h1>
    <fieldset><h2> Name and Address</h2>
    First Name&nbsp; <input type="text" value="First Name" name="First_Name" size="20" onfocus="if(this.value=='First Name') this.value = '';" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080;">&nbsp;
    Last Name&nbsp;<input type="text" value="Last Name" name="Last_Name" size="20" onfocus="if(this.value=='Last Name') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0;color:#008080"><br>
    <br>
    Street Address 1&nbsp;<input type="text" name="Street_Address" size="50" value="Address 1" onfocus="if(this.value=='Address 1') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br>
    <br>
    City&nbsp;<input type="text" name="City" size="30" value="City" onfocus="if(this.value=='City') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0;color:#008080">&nbsp;
    State&nbsp;<input type="text" name="State" size="10" value="State" onfocus="if(this.value=='State') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0;color:#008080">&nbsp;
    Zip&nbsp;<input type="text" name="Zip_Code" size="10" value="Zip" onfocus="if(this.value=='Zip') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br>
    <br>
    Phone&nbsp;<input type="text" name="Phone_Number" size="20" value="Phone" onfocus="if(this.value=='Phone') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">&nbsp;
    Fax&nbsp;<input type="text" name="Fax_Number" size="20" value="Fax" onfocus="if(this.value=='Fax') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br></fieldset>
    <br>
    Name as you would like it to appear on your badge&nbsp;<input type="text" size="15" value="Name" name="Badge_Name" onfocus="if(this.value=='Name') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br>
    <br>
    <i>Special Requests</i>
    <br>
    <fieldset><h2> Billing Information</h2>
    <br>
    Payment Method?&nbsp;<input type="radio" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="payment_method">&nbsp;Visa&nbsp;<input type="radio" Name="payment_method" style="border:1px solid #FFFF00; background-color:#C0C0C0">&nbsp;Master Card&nbsp;<input type="radio" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="payment_method">&nbsp;American Express<br>
    <br>
    Credit Card Number&nbsp;<input type="text" size="20" name="Credit_Card" value="CC #" onfocus="if(this.value=='CC #') this.value = '';"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br>
    <br>
    Expiration Month&nbsp;<select size="1" name="Exp.Month" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Month</option>
    	<option>January</option>
    	<option>February</option>
    	<option>March</option>
    	<option>April</option>
    	<option>May</option>
    	<option>June</option>
    	<option>July</option>
    	<option>Augest</option>
    	<option>September</option>
    	<option>October</option>
    	<option>November</option>
    	<option>December</option>
    	</select>&nbsp;Expiration Year&nbsp;<select size="0" name="exp. Year" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Year</option>
    	<option>2000</option>
    	<option>2001</option>
    	<option>2002</option>
    	<option>2003</option>
    	<option>2004</option>
    	<option>2005</option>
    	<option>2006</option>
    	<option>2007</option>
    	<option>2008</option>
    	<option>2009</option>
    	<option>2010</option>
    	<option>2011</option>
    	</select><br></fieldset>
    	<br>
    	<fieldset><h2> Travel Information</h2>
    	<br>
    	Hotal Check In&nbsp;<select size="1" name="check_in_month" value="Month" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    		<option selected>Month</option>
    		<option>January</option>
    		<option>February</option>
    		<option>March</option>
    		<option>April</option>
    		<option>May</option>
    		<option>June</option>
    		<option>July</option>
    		<option>Augest</option>
    		<option>September</option>
    		<option>October</option>
    		<option>November</option>
    		<option>December</option>
    	</select>&nbsp;<select size="0" name="check_in_day" value="day" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Day</option>
    	<option>1</option>
    	<option>2</option>
    	<option>3</option>
    	<option>4</option>
    	<option>5</option>
    	<option>6</option>
    	<option>7</option>
    	<option>8</option>
    	<option>9</option>
    	<option>10</option>
    	<option>11</option>
    	<option>13</option>
    	<option>14</option>
    	<option>15</option>
    	<option>16</option>
    	<option>17</option>
    	<option>18</option>
    	<option>19</option>
    	<option>20</option>
    	<option>21</option>
    	<option>22</option>
    	<option>23</option>
    	<option>24</option>
    	<option>25</option>
    	<option>26</option>
    	<option>27</option>
    	<option>28</option>
    	<option>29</option>
    	<option>30</option>
    	<option>31</option>
    	</select>&nbsp;<select size="0" name="Check_in_year" value="year" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Year</option>
    	<option>2000</option>
    	<option>2001</option>
    	<option>2002</option>
    	<option>2003</option>
    	<option>2004</option>
    	<option>2005</option>
    	<option>2006</option>
    	<option>2007</option>
    	<option>2008</option>
    	<option>2009</option>
    	<option>2010</option>
    	<option>2011</option>
    	</select>&nbsp;Hotal Check out&nbsp;<select size="1" name="check_out_month" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    		<option selected>Month</option>
    		<option>January</option>
    		<option>February</option>
    		<option>March</option>
    		<option>April</option>
    		<option>May</option>
    		<option>June</option>
    		<option>July</option>
    		<option>Augest</option>
    		<option>September</option>
    		<option>October</option>
    		<option>November</option>
    		<option>December</option>
    	</select>&nbsp;<select size="0" name="check_out_day" value="day" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Day</option>
    	<option>1</option>
    	<option>2</option>
    	<option>3</option>
    	<option>4</option>
    	<option>5</option>
    	<option>6</option>
    	<option>7</option>
    	<option>8</option>
    	<option>9</option>
    	<option>10</option>
    	<option>11</option>
    	<option>13</option>
    	<option>14</option>
    	<option>15</option>
    	<option>16</option>
    	<option>17</option>
    	<option>18</option>
    	<option>19</option>
    	<option>20</option>
    	<option>21</option>
    	<option>22</option>
    	<option>23</option>
    	<option>24</option>
    	<option>25</option>
    	<option>26</option>
    	<option>27</option>
    	<option>28</option>
    	<option>29</option>
    	<option>30</option>
    	<option>31</option>
    	</select><br>
    	<br>
    	Room Preference &nbsp;<input type="radio" name="Room_Pref" style="border:1px solid #FFFF00; background-color:#C0C0C0">&nbsp;Non-Smoking&nbsp;<input type="radio" Name="Room_Pref" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="rp">&nbsp;Smoking<br>
    	<br>
    	No. Of People&nbsp;<input type="text" name="num_of_people" size="20"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br>
    <br>
    I Require Airline Reservations? &nbsp;<input type="radio" name="Airline_Reserv." style="border:1px solid #FFFF00; background-color:#C0C0C0" name="rar">&nbsp;Yes&nbsp;<input type="radio" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="rar">&nbsp;No<br>
    <br>
    Departure City&nbsp;<input type="text" size="20"name="Depture_city" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br>
    <br>
    Arrival Date for Air&nbsp;<select size="1" name="Arrival_Month" value="Month" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    		<option selected>Month</option>
    		<option>January</option>
    		<option>February</option>
    		<option>March</option>
    		<option>April</option>
    		<option>May</option>
    		<option>June</option>
    		<option>July</option>
    		<option>Augest</option>
    		<option>September</option>
    		<option>October</option>
    		<option>November</option>
    		<option>December</option>
    	</select>&nbsp;<select size="0" name="menu" value="Arrival_Day" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Day</option>
    	<option>1</option>
    	<option>2</option>
    	<option>3</option>
    	<option>4</option>
    	<option>5</option>
    	<option>6</option>
    	<option>7</option>
    	<option>8</option>
    	<option>9</option>
    	<option>10</option>
    	<option>11</option>
    	<option>13</option>
    	<option>14</option>
    	<option>15</option>
    	<option>16</option>
    	<option>17</option>
    	<option>18</option>
    	<option>19</option>
    	<option>20</option>
    	<option>21</option>
    	<option>22</option>
    	<option>23</option>
    	<option>24</option>
    	<option>25</option>
    	<option>26</option>
    	<option>27</option>
    	<option>28</option>
    	<option>29</option>
    	<option>30</option>
    	<option>31</option>
    	</select>&nbsp;<select size="0" name="Arival_Year" value="year" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    	<option selected>Year</option>
    	<option>2000</option>
    	<option>2001</option>
    	<option>2002</option>
    	<option>2003</option>
    	<option>2004</option>
    	<option>2005</option>
    	<option>2006</option>
    	<option>2007</option>
    	<option>2008</option>
    	<option>2009</option>
    	<option>2010</option>
    	<option>2011</option>
    	</select><br>
    	<br>
    	Departure Date for Air&nbsp;<select size="1" name="Departure_Month" value="Month" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    			<option selected>Month</option>
    			<option>January</option>
    			<option>February</option>
    			<option>March</option>
    			<option>April</option>
    			<option>May</option>
    			<option>June</option>
    			<option>July</option>
    			<option>Augest</option>
    			<option>September</option>
    			<option>October</option>
    			<option>November</option>
    			<option>December</option>
    		</select>&nbsp;<select size="0" name="Departure_day" value="day" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    		<option selected>Day</option>
    		<option>1</option>
    		<option>2</option>
    		<option>3</option>
    		<option>4</option>
    		<option>5</option>
    		<option>6</option>
    		<option>7</option>
    		<option>8</option>
    		<option>9</option>
    		<option>10</option>
    		<option>11</option>
    		<option>13</option>
    		<option>14</option>
    		<option>15</option>
    		<option>16</option>
    		<option>17</option>
    		<option>18</option>
    		<option>19</option>
    		<option>20</option>
    		<option>21</option>
    		<option>22</option>
    		<option>23</option>
    		<option>24</option>
    		<option>25</option>
    		<option>26</option>
    		<option>27</option>
    		<option>28</option>
    		<option>29</option>
    		<option>30</option>
    		<option>31</option>
    		</select>&nbsp;<select size="0" name="Departure_year" value="year" style="border:2px solid yellow; background-color:#C0C0C0; color:#008080">
    		<option selected>Year</option>
    		<option>2000</option>
    		<option>2001</option>
    		<option>2002</option>
    		<option>2003</option>
    		<option>2004</option>
    		<option>2005</option>
    		<option>2006</option>
    		<option>2007</option>
    		<option>2008</option>
    		<option>2009</option>
    		<option>2010</option>
    		<option>2011</option>
    	</select><br>
    	<br>
    	Frequent Flyer No. and Airline&nbsp;<input type="text" name="Freq.flyer_no._airline" size="20"style="border:2px solid yellow; background-color:#C0C0C0; color:#008080"><br></fieldset>
    <br>
    <fieldset><h2> Other Activites You Would Like Scheduled</h2>
    <br>
    <input type="checkbox" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="Activ.Golf">&nbsp;Golf&nbsp;<input type="Checkbox" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="Activ_Diving">&nbsp;Diving&nbsp;<input type="checkbox" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="Activ_Tennis">&nbsp;Tennis&nbsp;<input type="Checkbox" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="Activ_Sailing">&nbsp;Sailing&nbsp;<input type="checkbox" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="Activ_Biking">&nbsp;Mountain Biking&nbsp;<input type="Checkbox" style="border:1px solid #FFFF00; background-color:#C0C0C0" name="Activ_Sight">&nbsp;Sight Seeing<br></fieldset>
    <br>
    <br>
    <input type="submit" value="Submit" onclick = "submitForm()" />
    <input type="reset" value="Reset"
    </form>
    </html>
    ---------------
    if there is anything else you need for you to help me please ask...Thank You
    Last edited by Hy Tek; 03-13-2005 at 12:47 AM.

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You spelt alert wrong...fix that and post back what happends

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Nothing Happend

    Lol i cant believe i spelled alert wrong, It still doesn't check to see if the fields where filled or not.. it just goes to the confirmation page

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Firstly, document.forms[]. One way you can access a form element like this: document.forms[0].element.value; as opposed to what you have. document.form[0].name_Last_Name.value. It also seems kind of pointless to check for empty fields, when your setting a default value? Look into those and see if you can get it going.

  • #5
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ty

    Well my teacher wanted us to check for the empty fields , i did what they had out of the book, i sent her the email with my code for her to help me out, sence it is what she wanted us to do, so thank you for trying to help.. i appreciate your time..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •