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 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Forms.....arg!!!

    Hey Guys:

    I've been pulling my hair out with this stupid thing, I have to validate this stupid form as well as check to see if there is cookies and add them if they haven't. I know most of you probably are pros at this! So I am requesting some assistance. Please see the code attached, let me know what to do. As well I can't get something that will work with my radio buttons to validate as well as cookies. I'll be forever grateful to any helpers! Thank You in Advance! This is what I have so far!
    Code:
    <html>
    <head>
    <title>Registration</title>
    <script language="Javascript">
    function ValidateRegistration()
    {
    	var first = document.Registration.fname;
    	var last = document.Registration.lname;
    	var addy = document.Registration.address;
    	var tele = document.Registration.telephone;
    	var mail = document.Registration.email;
    	var cc = document.Registration.card;
    	var what = document.Registration.age;
    	if (first.value == "")
    	{
    		window.alert("Please enter your first name!);
    		first.focus();
    		return false;
    	}
    	if (last.value == " ")
    	{
    		window.alert("Please enter your last name!);
    		last.focus();
    		return false;	
    	}
    	if (addy.value == "")
    	{
    		window.alert("Please enter your address");
    		addy.focus();
    		return false;
    	}
    	if (tele.value == "")
    	{
    		window.alert("Please enter your telephone");
    		tele.focus();
    		return false;
    	}
    	if (mail.value == "")
    	{
    		window.alert("Please enter your e-mail!");
    		email.focus();
    		return false;
    	}
    	if (mail.value.indexOf("@", 0) < 0)
    	{
    		window.alert("Please enter a valid e-mail address");
    		email.focus();
    		return false;
    	}
    	if (mail.value.indexOf(".", 0) < 0)
    	{
    		window.alert("Please enter a valid e-mail address!");
    		email.focus();
    		return false;
    	}
    	if (what.selectedIndex < 1)
    	{
    		alert("Please select your age range!");
    		what.focus();
    		return false;
    	}
    	return true;
    }
    
    </script>
    </head>
    <body>
    		<font size="4" face="ARIAL, HELVETICA" color="blue">
    		<b>Please enter the following data</b></font><br/>   
    <form name="Registration" action="processRegistration.asp" method="POST" onSubmit="return ValidateRegistration();">
        <p><font size="4" face="arial, helvetica">
        <table>
        <tr>
        <td>First name:</td>
        <td><input type="text" name="fname" size="20"></td>
        </tr>
        <tr>
        <td>Last name:</td>
        <td><input type="text" name="lname" size="20"></td>
        </tr>
        <tr>
        <td>Address:</td>
        <td><input type="text" name="address" size="20"></td>
        </tr>
        <tr>
        <td>Telephone Number:</td>
        <td><input type="text" name="telephone" size="20"></td>
        </tr>	
        <tr>
        <td>Email:</td>
        <td><input type="text" name="email" size="20"></td>
        </tr>
        <tr>
        <td>Please input your Credit Card Type:	</td>
        <tr>
        <td><input type="radio" name="card" id="r1" value="mastercard"> MasterCard</td></tr>
        <tr><td><input type="radio" name="card" id="r2" value="visa"> VISA</td></tr>
       	<tr><td><input type="radio" name="card" id="r3" value="amex"> American Express</td></tr>
        <tr><td><input type="radio" name="card" id="r4" value="other"> Other</td></tr>
        <tr>
        <td>Choose your age range:</td></tr>
        <td>
    	<select name="age"> 
    		<option value="10-20">10-20
    		</option>
    		<option value="21-30">21-30
    		</option>
    		<option value="31-40">31-40
    		</option>
    		<option value="41-50">41-50
    		</td>
        </option>
        </select><br/>
        <table>
        <tr><td><input type="submit" value="OK" name="submit">
        <input type="Reset" value="Cancel" name="reset"></td></tr>	
        </font>
        </p><font size="4" face="arial, helvetica"></font>
        </form>
    </body>
    </html>

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Please don't cross post.

    Validation and Cookies for forms...


  •  

    Posting Permissions

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