Hey can someone help me :)

Discussion in 'JavaScript' started by DMC1992, May 29, 2010.

  1. #1
    Hi all iv been posting here for a few weeks now getting help and you guys have been great, well heres whats up iv had to type up a Orderform in javascript my problem is i cant work out how to make number and letter only areas :( can anyone gave me a line of code? heres what iv made so far, if possible add the line of code onto mine so i can see how she goes together :) thanks all

    <html>
    <head>
    <title>Joe's Fruit Shop Order Form</title>
    <script language="javascript" type="text/javascript">

    <!-- hide script from older browsers
    function validateForm(contact)
    {

    if(document.forms.contact.fullName.value=="")
    {
    alert("Please enter your full name.");
    document.forms.contact.fullName.focus();
    return false;
    }

    if(document.forms.contact.homephone.value=="")
    {
    alert("Please enter your phone number.");
    document.forms.contact.homephone.focus();
    return false;
    }

    if(document.forms.contact.email.value=="")
    {
    alert("Please enter your email address.");
    document.forms.contact.email.focus();
    return false;
    }

    if(document.forms.contact.address.value=="")
    {
    alert("Please enter your address.");
    document.forms.contact.address.focus();
    return false;
    }

    if(document.forms.contact.citysuburb.value=="")
    {
    alert("Please enter your city\suburb.");
    document.forms.contact.citysuburb.focus();
    return false;
    }

    if(document.forms.contact.state.value=="")
    {
    alert("Please select your state.");
    document.forms.contact.state.focus();
    return false;
    }

    if(document.forms.contact.postcode.value=="")
    {
    alert("Please enter your post code.");
    document.forms.contact.postcode.focus();
    return false;
    }

    if(document.forms.contact.cardtype.value=="")
    {
    alert("Please select card Type.");
    document.forms.contact.cardtype.focus();
    return false;
    }

    if(document.forms.contact.month.value=="")
    {
    alert("Please select your Card Expiry Month.");
    document.forms.contact.month.focus();
    return false;
    }

    if(document.forms.contact.year.value=="")
    {
    alert("Please select your Card Expiry Year.");
    document.forms.contact.year.focus();
    return false;
    }

    if(document.forms.contact.cardnumber.value=="")
    {
    alert("Please enter your Card Number.");
    document.forms.contact.cardnumber.focus();
    return false;
    }

    if(document.forms.contact.cardholder.value=="")
    {
    alert("Please enter the Card Holder's Name.");
    document.forms.contact.cardholder.focus();
    return false;
    }

    if(document.forms.contact.item1.value=="")
    {
    alert("Please select an Item you must make at least 1 selection.");
    document.forms.contact.item1.focus();
    return false;
    }

    if(document.forms.contact.quantity1.value=="")
    {
    alert("Please select the quantity of the item you would like you must make at least 1 selection.");
    document.forms.contact.quantity1.focus();
    return false;
    }

    if(document.forms.contact.item2.value=="")
    {
    alert("Please select an Item.");
    document.forms.contact.item2.focus();
    return false;
    }

    if(document.forms.contact.quantity2.value=="")
    {
    alert("Please select the quantity of the item you would like.");
    document.forms.contact.quantity2.focus();
    return false;
    }

    if(document.forms.contact.item3.value=="")
    {
    alert("Please select an Item.");
    document.forms.contact.item3.focus();
    return false;
    }

    if(document.forms.contact.quantity3.value=="")
    {
    alert("Please select the quantity of the item you would like.");
    document.forms.contact.quantity3.focus();
    return false;
    }

    if(document.forms.contact.item4.value=="")
    {
    alert("Please select an Item.");
    document.forms.contact.item4.focus();
    return false;
    }

    if(document.forms.contact.quantity4.value=="")
    {
    alert("Please select the quantity of the item you would like.");
    document.forms.contact.quantity4.focus();
    return false;
    }

    if(document.forms.contact.item5.value=="")
    {
    alert("Please select an Item.");
    document.forms.contact.item5.focus();
    return false;
    }

    if(document.forms.contact.quantity5.value=="")
    {
    alert("Please select the quantity of the item you would like.");
    document.forms.contact.quantity5.focus();
    return false;
    }

    }
    stop hiding script -->
    </script>

    </head>
    <body>
    <h2>Joe's Fruit Shop Order Form</h2> <p>Your details and delivery address: Regions that contain a "*" are required</p>

    <form name="contact" method="post" action="" onSubmit="return validateForm(contact);">

    <table border="1">

    <tr>
    <td>*Full Name:</td>
    <td><input type="text" name="fullName" length="25"></td>
    <td>*Home Phone:</td>
    <td><input type="text" name="homephone" length="25"></td>
    </tr>

    <tr>
    <td>Mobile Phone:</td>
    <td><input type="text" name="mobilephone" length="25"></td>
    <td>Work Phone:</td>
    <td><input type="text" name="workphone" length="25"></td>
    </tr>

    <tr>
    <td>*E-Mail:</td>
    <td><input type="text" name="email" length="25"></td>
    <td>*Address:</td>
    <td><input type="text" name="address" length="25"></td>
    </tr>

    <tr>
    <td>*City Suburb:</td>
    <td><input type="text" name="citysuburb" length="25"></td>
    <td>*State:</td>
    <td>
    <SELECT name="state">
    <OPTION SELECTED value="">State
    <OPTION value="1">QLD
    <OPTION value="2">NSW
    <OPTION value="3">ACT
    <OPTION value="4">VIC
    <OPTION value="5">TAS
    <OPTION value="6">SA
    <OPTION value="7">NT
    <OPTION value="8">WA
    </SELECT>
    </td>
    </tr>
    <tr>
    <td>*Post Code:</td>
    <td><input type="text" name="postcode" length="25"></td>
    </tr>
    </table>

    <hr>
    <p>*Credit card details:</p>

    <table border="1">
    <tr>
    <td>*Card Type</td>
    <td>
    <select name="cardtype">
    <option>Please select card type</option>
    <option value="1">Visa</option>
    <option value="2">Master Card</option>
    <option value="3">AMX</option>
    </select>
    </td>
    <td>*Expiry date:</td>
    <td>
    <select name="month">
    <OPTION SELECTED value="">Month
    <option value="1">Jan
    <option value="2">Fab
    <option value="3">Mar
    <option value="4">Apr
    <option value="5">May
    <option value="6">Jun
    <option value="7">Jul
    <option value="8">Aug
    <option value="9">Sep
    <option value="10">Oct
    <option value="11">Nov
    <option value="12">Dec
    </select>
    <select name="year">
    <OPTION SELECTED value="">Year
    <option value="1">2009
    <option value="2">2010
    <option value="3">2011
    <option value="4">2012
    <option value="5">2013
    </select>
    </td>
    </tr>

    <tr>
    <td>*Card Number:</td>
    <td><input type="text" name="cardnumber" length="25"></td>
    <td>*Card holder's name:</td>
    <td><input type="text" name="cardholder" length="25"></td>
    </tr>
    </table>

    <hr>
    <p>*Purchase details:</p>

    <table border="1">
    <tr><td>*Item choises and Quantity.</td></tr>
    <tr><td>
    <select name="item1">
    <OPTION SELECTED value="">Item
    <option value="1">Alfalfa sprouts $1.50 per punnet
    <option value="2">Apples, Bonza $5.99KG
    <option value="3">Apples, Golden Delicious $4.99KG
    <option value="4">Artichoke hearts, pickled $17.99KG
    <option value="5">Avocados, dark, large 2 for $3.50
    </select>
    <select name="quantity1">
    <OPTION SELECTED value="">Quantity
    <option value="1">1
    <option value="2">2
    <option value="3">3
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7
    <option value="8">8
    <option value="9">9
    <option value="10">10
    </select>
    </tr></td>

    <tr><td>
    <select name="item2">
    <OPTION SELECTED value="0">Item
    <option value="1">Alfalfa sprouts $1.50 per punnet
    <option value="2">Apples, Bonza $5.99KG
    <option value="3">Apples, Golden Delicious $4.99KG
    <option value="4">Artichoke hearts, pickled $17.99KG
    <option value="5">Avocados, dark, large 2 for $3.50
    </select>
    <select name="quantity2">
    <OPTION SELECTED value="0">Quantity
    <option value="1">1
    <option value="2">2
    <option value="3">3
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7
    <option value="8">8
    <option value="9">9
    <option value="10">10
    </select>
    </tr></td>

    <tr><td>
    <select name="item3">
    <OPTION SELECTED value="0">Item
    <option value="1">Alfalfa sprouts $1.50 per punnet
    <option value="2">Apples, Bonza $5.99KG
    <option value="3">Apples, Golden Delicious $4.99KG
    <option value="4">Artichoke hearts, pickled $17.99KG
    <option value="5">Avocados, dark, large 2 for $3.50
    </select>
    <select name="quantity3">
    <OPTION SELECTED value="0">Quantity
    <option value="1">1
    <option value="2">2
    <option value="3">3
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7
    <option value="8">8
    <option value="9">9
    <option value="10">10
    </select>
    </tr></td>

    <tr><td>
    <select name="item4">
    <OPTION SELECTED value="0">Item
    <option value="1">Alfalfa sprouts $1.50 per punnet
    <option value="2">Apples, Bonza $5.99KG
    <option value="3">Apples, Golden Delicious $4.99KG
    <option value="4">Artichoke hearts, pickled $17.99KG
    <option value="5">Avocados, dark, large 2 for $3.50
    </select>
    <select name="quantity4">
    <OPTION SELECTED value="0">Quantity
    <option value="1">1
    <option value="2">2
    <option value="3">3
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7
    <option value="8">8
    <option value="9">9
    <option value="10">10
    </select>
    </tr></td>

    <tr><td>
    <select name="item5">
    <OPTION SELECTED value="0">Item
    <option value="1">Alfalfa sprouts $1.50 per punnet
    <option value="2">Apples, Bonza $5.99KG
    <option value="3">Apples, Golden Delicious $4.99KG
    <option value="4">Artichoke hearts, pickled $17.99KG
    <option value="5">Avocados, dark, large 2 for $3.50
    </select>
    <select name="quantity5">
    <OPTION SELECTED value="0">Quantity
    <option value="1">1
    <option value="2">2
    <option value="3">3
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7
    <option value="8">8
    <option value="9">9
    <option value="10">10
    </select>
    </tr></td>
    </table>

    <table>
    <tr><td>Click <b>Submit</b> to submit the order form, click <b>Reset</b> to reset the form.</td></tr>
    <tr>
    <td>
    <input type="submit" name="submit" value="Submit">
    </td>
    <td><input type="reset" name="reset"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
     
    DMC1992, May 29, 2010 IP
  2. DMC1992

    DMC1992 Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    bump anyone?
     
    DMC1992, May 29, 2010 IP