show values of correct log in form

Erica31
Erica31 used Ask the Experts™
on
I have had to create script to validate a log in form! Last but not least i have to show all correct values! Attached is what i have, can someone help me?? form.html
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014

Commented:
Hmmm... it seems you need to work a lot on it :))

this is what I see in your form.html attached :
Maybe I have a virus ? 8-(
}
	   if (errors == 0 ) 
		  (values = document.form1.elements);
			alert('No errors');{

Open in new window

leakim971Multitechnician
Top Expert 2014

Commented:
@Erica31, please check your submited form.html

Author

Commented:
Sorry that was just the "if" part that i am working on to show all values! I will attach whole javascript.
register31.html
Multitechnician
Top Expert 2014
Commented:
check this :


<!-- saved from url=(0022)http://internet.e-mail -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html lang="en-au">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <style type="text/css" media="screen">
				@import url(../styles/ips2.css);
		</style>
<style type="text/css" media="screen">
				@import url(../styles/unit2.css);
		</style>
<link href="../styles/ips2_print.css" media="print" type="text/css" rel="stylesheet" />


<title>Login form</title>
<script type="text/javascript" language="javascript">

	function validate()
	{
		var tbs = new Array();tbs["firstname"] = "First Name";tbs["lastname"]="Last Name";tbs["email"]="Email";tbs["age"]="Age";
		var allTextboxesAreNotEmpty = true;
		var textboxes = document.forms["form1"].getElementsByTagName("input");
		for(var i=0;i<textboxes.length;i++) {
			if(textboxes[i].value.length == 0) {
				allTextboxesAreNotEmpty = false;
				alert("You left the " + tbs[textboxes[i].name] + " empty!");
			}
		}

		var emailIsValid = checkEmail( document.getElementById("email").value ); 
		if(!emailIsValid) alert("Email is not valid!");
		
		var isAdult = adulthood(  document.getElementById("age").value );
		if(!isAdult) alert("You must be adult!");

		var stateIsSelected = (document.getElementById("state").selectedIndex > 0)
		if(!stateIsSelected) alert("State not selected!");
		
		return allTextboxesAreNotEmpty && emailIsValid && isAdult && stateIsSelected;	
	}
	
	
	function checkEmail(email) 
	{
		return /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(email);
	}
	
	function adulthood(age)
	{
		return parseInt(age) >= 18;
	}

</script>
</head>		

  <body>
  <noscript>This page is better viewed with JavaScript enabled</noscript>
<a name="a" id="a" class="tocMarker"></a>

<div class="lyrTop" id="lyrTop">
<span class="topNav">
			| <a href="#" class="topNav" onClick="printPage();" onKeyPress="return handleEnter(ACTION_PRINT,event);">Print</a>
			| <a href="#" class="topNav" onClick="window.close(); return false;" onKeyPress="return handleEnter(ACTION_CLOSE,event);">Close</a> |
</span>
<noscript><span>[Javascript disabled - To close this window, press Ctrl + W (PC), or APPLE + W (Mac)]</span></noscript>
</div>
	<form name="form1" action="#" method="get" onSubmit="return validate();">
	   <div style=" margin-left:100;background-color:#F9FAE7;width:300">
	   <table>
	   <tr><td colspan="2"><h1>Flex-IT Registration</h1></td></tr>
	   <tr><td></td></tr>
	   <tr><td > First name:</td><td><input type="text" id="firstname" name="firstname" /></td></tr>
	    <tr><td>Last name: </td><td><input type="text" id="lastname" name="lastname" /></td></tr>
	    <tr><td>Email: </td><td><input id="email" name="email" size="35"  /></td></tr>
	    <tr><td>Age: </td><td><input id="age" name="age" size="3" maxlength="2"/></td></tr>
	    <tr><td>State</td><td><select id="state" name="state">
	       <option value="" selected="selected">Choose a state...</option>
	       <option value="NSW">NSW</option>
	       <option value="QLD">QLD</option>
	       <option value="VIC">VIC</option>
	       <option value="SA">SA</option>
	       <option value="WA">WA</option>
	       <option value="TAS">TAS</option>
	       <option value="NT">NT</option>
	       </select></td></tr>
	       </table>
	     <tr><td><input type="button" value="Submit" onClick="validate()"/></td></tr>  
	   </div> 
	</form>
  </body>
</html>

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial