473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

why not move to new page?

hello

the code below checks for a valid email address and then should move to either of 2 pages but no move happens! Why?

Thanks

Geoff

[HTML]<script>
function getNextPage(){
var num = Math.random();
if (num<.5) {
alert('going to 1');
location.href='group1/group1-lab1.htm';
} else {
alert('going to 2');
location.href='group2/group2-lab1.htm';
}
}

function validateEmail ( emailField, errorMsg ) {
emailpat =
/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
if( !emailpat.test( emailField.value ) ) {
alert( errorMsg);
emailField.focus();
emailField.select();
return false;
} else {
//return true;
parent.frame_top.top_value = emailField.value;
document.getElementById('mail').className='hiddenD iv';
getNextPage();
}
}

//-->
</script>
</script>
</head>
<body>

<h2>test</h2>

<div id="mail" class="visibleDiv">
<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>
</div>[/HTML]
May 4 '08 #1
1 1310
hsriat
1,654 Expert 1GB
Remove the duplicate script end tag.

Also, if you have to redirect the page to another page, what's the need of the email validation? I guess you want to change the action of the form instead of redirecting the browser.

For that, in the end of second function, instead of writing getNextPage(), write return getNextPage() there.

And modify your getNextPage() function like this...
Expand|Select|Wrap|Line Numbers
  1. function getNextPage(){
  2.     var num = Math.random();
  3.     if (num<0.5) {
  4.         alert('going to 1');
  5.         document.forms['emailForm'].action='group1/group1-lab1.htm';
  6.     }
  7.     else {
  8.         alert('going to 2');
  9.         document.forms['emailForm'].action='group2/group2-lab1.htm';
  10.     }
  11. return true; //important
  12. }
And don't forget this when you post here next time:
[code] --- your code --- [/code] (Use code tags)
May 5 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Galina | last post by:
Hello I have an Access 2000 application. The form has got a tab with 3 pages. There are several text boxes and command buttons on one page. I need to move them to another page (to free form space...
4
by: Vincent Yang | last post by:
I'm using Access 2002. My database is in Access 2000 format. I'm designing a form to collect responses to a 40-item questionnaire. I can fit four list boxes on a screen, so I plan to have 11 tab...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
1
by: Patrick | last post by:
Hi, I have a xml file like this: <?xml version="1.0"?> <home> <page name="Test1" id="1"> <page name="Pagetest1" id="2" src="test1.htm"></page> <page name="pagetest3" id="3"...
5
by: DL | last post by:
Hi, My research on this NG hasn't produced a satisfactory answer. Here's what I want to do: move two div (s) (each has an image tag within) to another location on the same page. // no...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.