Registration Form


Please fill out the fields below to register for our web page. Press the Submit button at the end of the form when done.
Your Name:
Your Phone Number:
E-mail address:
Mailing address:
City, State, Zip:

 

  • Source

    <HTML>
    <HEAD><TITLE>Registration Form</TITLE>
    <SCRIPT>
    //global variable for error flag
    var errfound = false;
    //function to validate by length
    function ValidLength(item, len) {
       return (item.length >= len);
    }
    //function to validate an email address
    function ValidEmail(item) {
       if (!ValidLength(item, 5)) return false;
       if (item.indexOf ('@', 0) == -1) return false;
       return true;
    }
    // display an error alert
    function error(elem, text) {
    // abort if we already found an error
       if (errfound) return;
       window.alert(text);
       elem.select();
       elem.focus();
       errfound = true;
    }
    // main validation function
    function Validate() {
       errfound = false;
       if (!ValidLength(document.regform.username.value,6))
          error(document.regform.username,"Invalid Name");
       if (!ValidLength(document.regform.phone.value,10))
          error(document.regform.phone,"Invalid phone number");
       if (!ValidEmail(document.regform.email.value))
          error(document.regform.email, "Invalid Email Address");
       if (!ValidLength(document.regform.address.value,10))
          error(document.regform.address, "Invalid Mailing Address");
       if (!ValidLength(document.regform.city.value,15))
          error(document.regform.city, "Invalid City/State/Zip");
       return !errfound; /* true if there are no errors */
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <H1>Registration Form</H1>
    <HR>
    Please fill out the fields below to register for our web page. Press the
    Submit button at the end of the form when done.
    <HR>
    <FORM NAME="regform" onSubmit="return Validate();"
    ACTION="mailto:username@host" METHOD="post">
    <B>Your Name:</B>
    <INPUT TYPE="text" NAME="username" SIZE=20><BR>
    <B>Your Phone Number: </B>
    <INPUT TYPE="text" NAME="phone" SIZE=15><BR>
    <B>E-mail address:</B>
    <INPUT TYPE="text" NAME="email" SIZE=20><BR>
    <B>Mailing address:</B>
    <INPUT TYPE="text" NAME="address" SIZE=30><BR>
    <B>City, State, Zip:</B>
    <INPUT TYPE="text" NAME="city" SIZE=30>
    <HR>
    <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Submit Registration">
    <INPUT TYPE="RESET" VALUE="Start Over">
    </FORM>
    </BODY>
    </HTML>