Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > why not moving ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 35459 of 36382
Post > Topic >>

why not moving to new page after validation?

by Geoff Cox <gcox@[EMAIL PROTECTED] > May 2, 2008 at 05:51 PM

Hello

I cannot see why this is not working - the idea being to check the
email address entered and if OK to move to either of 2 pages - the
move does not happen.

The code below is in the lower of 2 frames.

Why?!

Cheers

Geoff


function getNextPage(){
var num = Math.random();
	if (num<.5) {
	 location.href="group1/group1-lab1.htm";
	} else {
 	 location.href="group2/group2-lab1.htm";
	}
}

function validateEmail ( emailField, errorMsg ) {
emailpat =
/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@[EMAIL PROTECTED]
([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
	 if( !emailpat.test( emailField.value ) ) {
	  alert( errorMsg);
	  emailField.focus();
	  emailField.select();
	  return false;
	 } else {
	   getNextPage();
	 }
}

//-->
</script>

</head>

<body>

<h2>test</h2>

<form name="emailForm" onsubmit="validateEmail( this.email , 'Please
enter a valid email address')">
Please enter your email address <input type="text" name="email">
<input type="submit" value="enter">
</form>
 




 1 Posts in Topic:
why not moving to new page after validation?
Geoff Cox <gcox@[EMAIL  2008-05-02 17:51:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 5:13:37 CDT 2008.