仍然希望得到一点帮助! [英] still hoping for a little help!

查看:73
本文介绍了仍然希望得到一点帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好


我看不出为什么这不起作用 - 想法是检查输入的

电子邮件地址,如果可以转到任何一个共2页 -

移动不会发生。


以下代码位于2帧的较低位置。


为什么?!


干杯


Geoff

function getNextPage(){

var num = Math.random();

if(num< .5){

location.href =" group1 / group1-lab1.htm" ;

}其他{

location.href =" group2 / group2-lab1.htm";

}

}


函数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();

返回false;

} else {

getN extPage();

}

}


// - >

< / script>


< / head>


< body>


< h2> test< / h2>


< form name =" emailForm" onsubmit =" validateEmail(this.email,''请

输入有效的电子邮件地址'')">

请输入您的电子邮件地址<输入类型= QUOT;文本" name =" email">

< input type =" submit" value =" enter">

< / form>

解决方案

/;

if(!emailpat.test(emailField.value)){

alert(errorMsg);

emailField.focus();

emailField.select();

返回false;

} else {

getNextPage();

} < br $>
}


// - >

< / script>


< / head>


< body>


< h2> test< / h2>

< form name =" emailForm" onsubmit =" validateEmail(this.email,''请

输入有效的电子邮件地址'')">

请输入您的电子邮件地址<输入类型= QUOT;文本" name =" email">

< input type =" submit" value =" enter">

< / form>


Geoff Cox写道:


我不明白为什么这不起作用 - 想法是检查输入的

电子邮件地址,如果可以转到2页中的任何一个 -

移动不会发生。



最简单的方法是通过添加警报。这显示了代码所采用的

路径,如果你提醒事物的值,

它会告诉你原因。例如:


函数getNextPage(){

var num = Math.random();

alert(" in getNextPage ,random num =" + num);

if(num< .5){

alert(" in getNextPage,< .5 logic")

location.href =" group1 / group1-lab1.htm" ;;

} else {

alert(" in getNextPage,follow else logic" ;)

location.href =" group2 / group2-lab1.htm";

}

}


2008年5月5日星期一11:47:59 +0200,Stevo< no@mail.invalidwrote:


> Geoff Cox写道:


>我看不出为什么这不起作用 - 想法是检查输入的
电子邮件地址,如果可以移动到2页之一 -
动作不会发生。


最简单的方法是通过添加警报。这显示了代码所采用的路径,如果你也提醒事物的价值,那么它会告诉你原因。示例:

函数getNextPage(){
var num = Math.random();
alert(" in getNextPage,random num =" + num);
if(num< .5){

alert(" in getNextPage,< .5 logic")
location.href =" group1 / group1-lab1.htm" ;
} else {

alert(在getNextPage中,在其他逻辑之后)

location.href =" group2 / group2-lab1.htm" ;
}
}



谢谢Stevo,我已经尝试了你的代码,但仍然不清楚为什么我的代码

不工作!


之后


alert(在getNextPage中,在< .5逻辑之后)


我只是看到原始的电子邮件地址输入而不是


group1 / group1-lab1.htm


其次是?!


干杯


Geoff


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 one 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_-])*@([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>

解决方案

/;
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>


Geoff Cox wrote:

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

The simplest way to find out is to add alerts throught. That shows the
path the code is taking, and if you alert the values of things too,
it''ll show you why. Example:

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


On Mon, 05 May 2008 11:47:59 +0200, Stevo <no@mail.invalidwrote:

>Geoff Cox wrote:

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


The simplest way to find out is to add alerts throught. That shows the
path the code is taking, and if you alert the values of things too,
it''ll show you why. Example:

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

Thanks Stevo, I have tried your code but still not clear why my code
isn''t working!

After

alert("in getNextPage, following<.5 logic")

I just see the original email address input and not

group1/group1-lab1.htm

Where next?!

Cheers

Geoff


这篇关于仍然希望得到一点帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆