dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help! Form Validation...

  1. #1
    Join Date
    Jan 2004
    Posts
    47

    Question Help! Form Validation...

    I am trying to validate the following form. I have three validations working but need to validate all but the M-F drop down menu.
    Can anyone help me?

    I have tried a validation that I found for zip codes, but when I add it to what I already have, it makes the entire form stop working. I am pasting what I have that is working. I took out the javascript that was making it not work.

    If anyone has an answer for me, I REALLY need you to be clear on how and where I call up the code.
    I was doing the zip code with an onBlur and I left the on Blur in the code so that you could see it.
    Thanks! You guys have always been great to me!!
    Cool

    <html>
    <head>

    <meta http-equiv="Content-Language" content="en-us">
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="Author" content="Linda Cooley">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>


    <SCRIPT LANGUAGE="JavaScript">


    /////////////////////////////////////////////////////////
    //Checking for the @ and the "dot" in an email
    /////////////////////////////////////////////////////////

    function isANumber(inputValue){

    // Assume everything is okay
    var result = true

    // If parseFloat() returns false, a non-numeric character
    // was detected in the first position
    if (!parseFloat(inputValue)) {
    result = false
    }

    // Otherwise, we still have to check the rest of the digits,
    // so step through the inputValue one character at
    // a time and set result = false if any non-numeric
    // digits are encountered.
    else {
    for (var i=0; i<inputValue.length; i++) {
    if (inputValue.charAt(i) != " ") {
    if (!parseFloat(inputValue.charAt(i))) {
    result = false
    break
    }
    }
    }
    }

    // Return true (inputValue is a valid number) or
    // false (it's invalid).
    return result
    }


    function isAValidEmail(inputValue) {

    var foundAt = false
    var foundDot = false
    var atPosition = -1
    var dotPosition = -1

    // Step through each character of the e-mail
    // address and set a flag when (and if) an
    // @ sign and a dot are detected.

    for (var i=0; i<=inputValue.length; i++) {
    if (inputValue.charAt(i) == "@" ) {
    foundAt = true
    atPosition = i
    }
    else if (inputValue.charAt(i) == ".") {
    foundDot = true
    dotPosition = i
    }
    }

    //If both an @ and a "." are found and in right order
    if ((foundAt && foundDot) && (atPosition < dotPosition)) {
    // It's a valid e-mail address

    return true
    }
    else {
    // The e-mail address is invalid
    alert("Sorry, you entered an invalid e-mail address. Please try again.")
    return false
    }
    }

    function exists(inputValue) {

    var aCharExists = false

    // Step through the inputValue, using the charAt()
    // method to detect non-space characters.

    for (var i=0; i<=inputValue.length; i++) {
    if (inputValue.charAt(i) != " " && inputValue.charAt(i) != "") {
    aCharExists = true
    break
    }
    }

    return aCharExists
    }



    </SCRIPT>



    <meta name="Microsoft Border" content="tl, default">
    </head>

    <body background="images/arg-dognut-207x165-url.gif">

    <p align="center">
    <span style="position: absolute; left: 163; top: 26; z-index: -1">
    <img border="0" src="images/TopGunOvalBlue3.gif" width="679" height="510"></span></p>
    <FORM action="http://www.response-o-matic.com/cgi-bin/rom.pl" method="POST" name="poll">
    <INPUT TYPE="hidden" NAME="your_email_address" VALUE="">
    <INPUT TYPE="hidden" NAME="your_name" VALUE="Lucius and Loretta">
    <INPUT TYPE="hidden" NAME="email_subject_line" VALUE="Top Gun Poll">
    <INPUT TYPE="hidden" NAME="required_fields" VALUE="">
    <INPUT TYPE="hidden" NAME="thank_you_title" VALUE="Thank you, from Top Gun Auto Body!">
    <INPUT TYPE="hidden" NAME="return_link_url" VALUE="">
    <INPUT TYPE="hidden" NAME="return_link_name" VALUE="Return to our Website">
    <INPUT TYPE="hidden" NAME="background_color" VALUE="#FFFF00">
    <INPUT TYPE="hidden" NAME="text_color" VALUE="#008000">
    <INPUT TYPE="hidden" NAME="link_color" VALUE="#008000">
    <INPUT TYPE="hidden" NAME="visited_link_color" VALUE="#8000FF">
    <INPUT TYPE="hidden" NAME="active_link_color" VALUE="#0000FF">
    <p align="center">&nbsp;
    <img border="0" src="images/name.gif" width="289" height="90">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
    <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="80%" id="AutoNumber1">
    <tr>
    <td width="100%" colspan="3">
    <p align="center"><font color="#FF3300"><b><font size="4">We would like to get an idea of
    the demographics <br>
    of our customers.<br>
    Would you please take our short poll?<br>
    Thanks!!<br>
    &nbsp;</font></b></font></td>
    </tr>
    <tr>
    <td width="36%">
    <p align="right"><font color="#FF3300">Male or Female:&nbsp;
    <select size="1" name="Male_or_Female">
    <option>M</option>
    <option>F</option>
    </select></font></td>
    <td width="27%">
    <p align="center"><font color="#FF3300">Your age:&nbsp;
    <input type="text" name="Age" size="3" onBlur="if (!exists(Age.value)) { alert('Please enter your age. Thanks!') }"></font></td>
    <td width="37%">
    <p align="left"><font color="#FF3300">Your zip code:
    <input type="text" name="Zip" size="10" onBlur="if(isANumber(Zip.value)) {alert('Thank you for entering your zip code.')} else {alert('Please enter a zip code.');}"></font></td>
    </tr>
    <tr>
    <td width="63%" colspan="2">
    <p align="center"><font color="#FF3300"><br>
    Your Email:<br>
    <input type="text" name="Email" size="35" onBlur="isAValidEmail(Email.value)"></font></td>
    <td width="37%">
    <p align="left"><font color="#FF3300"><br>
    Date of your visit with us:<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="Date" size="10">mm/dd/yy</font></td>
    </tr>
    </table>
    </center>
    </div>
    <p align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit" value="Submit"><input type="reset" value="Reset" name="B2"></p>
    </form>
    <p align="center">&nbsp;</p>
    <p align="center"><span style="position: absolute; left: 467; top: 346">
    <img border="0" src="images/arg-roadster-tr-cr-url.gif" width="245" height="128"></span></p>

    </body>

    </html>

  2. #2
    Join Date
    May 2004
    Posts
    1
    Hello, I need help with my signup page.Once I added a little coding the two fields (Password and Re-enter Password) when not the same wont popup a message anymore.Here is my coding copied.

    <html>
    <head>

    <style type="text/css">

    A:link
    { text-decoration: none; }

    body
    { background-color: #FFCC00; }

    </style>

    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function checkPw(form) {
    pw1 = form.pw1.value;
    pw2 = form.pw2.value;

    if (pw1 != pw2) {
    alert ("\nYou did not enter the same new password twice. Please re-enter your password.")
    return false;
    }
    else return true;
    }
    // End -->
    </script>
    <center>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function verify() {
    var themessage = "You are required to complete the following fields: ";
    if (document.form.first.value=="") {
    themessage = themessage + " - First Name";
    }
    if (document.form.last.value=="") {
    themessage = themessage + " - Last Name";
    }
    if (document.form.pw1.value=="") {
    themessage = themessage + " - Password";
    }
    if (document.form.pw2.value=="") {
    themessage = themessage + " - Confirm Password";
    }
    if (themessage == "You are required to complete the following fields: ") {
    document.form.submit();
    }
    else {
    alert(themessage);
    return false;
    }
    }
    // End -->
    </script>
    </center>
    </head>
    <body>
    <center>

    Under Construction<br>
    <br>
    <form name=form method="post" action="" onSubmit="return checkPw(this)">
    <center>
    First Name:<input type=text name="first" size="20"><BR>
    Last Name:<input type=text name="last" size="20"><BR>

    <table border=0>
    <tr>
    <td>Password:</td><td><input type=text name=pw1 size=10></td>
    </tr>
    <tr>
    <td>Re-enter:</td><td><input type=text name=pw2 size=10></td>
    </tr>
    <tr>
    <td colspan=2 align=center><input type=button value="Submit Request" onclick="verify();"></td>
    </tr>
    </table>
    <input type=reset value="Clear Form"><br>
    </form>

    </center>
    </body>
    </html>

  3. #3
    Join Date
    Jan 2004
    Posts
    47
    I am certainly no genius, but why do you have two sets of Javascript?
    I have never seen it done that way. Why don't you put it all in one?
    And...should it be...
    <body background-color="#whatever?">

    I'm still a student myself.
    Cool

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles