Required fields?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghostrider
    New Member
    • Jan 2007
    • 34

    Required fields?

    I'm trying to write a code that will verifiy that each field was fill in. And if not it would return with and error message. Can someone help with this, here is my code so far:

    [HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <!-- Created with the CoffeeCup HTML Editor 2007 -->
    <!-- http://www.coffeecup.c om/ -->
    <!-- Brewed on 2/18/2008 4:33:53 PM -->
    <head>
    <title>Custom er Information</title>
    </head>
    <head>
    <script type="text/javascript">
    function validate_requir ed(field,alertt xt)
    {
    with (field)
    {
    if (value==null||v alue=="")
    {alert(alerttxt );return false;}
    else {return true}
    }
    }function validate_form(t hisform)
    {
    with (thisform)
    {
    if (validate_requi red(email,"Emai l must be filled out!")==false)
    {email.focus(); return false;}
    }
    }
    </script>
    </head>
    <body>
    <form action="submitp age.htm" onsubmit="retur n validate_form(t his)"
    method="post">

    <form method="post" action="button. html">
    First name:
    <input type="text" name="firstname " size="20">
    <br>
    Last name:
    <input type="text" name="lastname" size="20">
    <br>
    Email Address:
    <input type="text" name="emailaddr ess" size="70">
    <br>
    Address:
    <input type="text" address="addres s" size "50">
    <br>
    City:
    <input type="text" city="city" size="20">
    <br>
    State:
    <input type="text" state="state" size="2">
    <br>
    Zip Code:
    <input type="text" zip code="zipcode" size="5">
    <br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>[/HTML]
    Last edited by acoder; Feb 22 '08, 08:57 AM. Reason: Added code tags
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    What is this line for?

    <form method="post" action="button. html">

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      ghostrider, please enclose your posted code in [code] tags (See How to Ask a Question).

      This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

      Please use [code] tags in future.

      Thanks!

      Comment

      Working...