indexOf不起作用? [英] indexOf does not work?

查看:103
本文介绍了indexOf不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有这个代码。当我输入 je***@ebay.com 时,它应该运行

alert(谢谢为了你的兴趣。)行。但事实并非如此。为什么和

如何更正呢?我使用IE 6和windows xp。

非常感谢。


< HTML>< body>

< form name =" myForm">

< INPUT TYPE =" text" VALUE =输入电子邮件 NAME =" userEmail"

onChange = validateInput()>

< / form>

< script type =" text / javascript">

this.myForm.userEmail.select()

函数validateInput(){

userInput = this.myForm.userEmail .value

document.write(userInput)

if(userInput.indexOf(''@'')> 0&& userInput.indexOf(''。 '')> 0)

提醒(感谢您的关注。)

其他

提醒("请检查

提交后,你的电子邮件详情是正确的。)

}

< / script>

Hi All,

I have this code. When I type in je***@ebay.com, it should run
alert("Thanks for your interest.") line. But it does not. Why and
how can I correct it? I use IE 6 with windows xp.
Thanks a lot.

<HTML><body>
<form name="myForm">
<INPUT TYPE="text" VALUE="Enter email" NAME="userEmail"
onChange=validateInput()>
</form>
<script type="text/javascript">
this.myForm.userEmail.select()
function validateInput() {
userInput = this.myForm.userEmail.value
document.write(userInput)
if (userInput.indexOf(''@'')>0 && userInput.indexOf(''.'')>0)
alert("Thanks for your interest.")
else
alert("Please check that your email details are correct before
submitting")
}
</script>

推荐答案

2004年9月25日22:25:02 -0700,在comp.lang.javascript中
je ************ @ hotmail.com (Jenny)写道:
On 25 Sep 2004 22:25:02 -0700, in comp.lang.javascript
je************@hotmail.com (Jenny) wrote:
|大家好,
|
|我有这个代码。当我输入 je***@ebay.com 时,它应该运行
|警告(感谢您的兴趣。)行。但事实并非如此。为什么和
|我怎么纠正呢?我使用IE 6与Windows XP。
|非常感谢。
|
| < HTML>< body>
| < form name =" myForm">
| < INPUT TYPE =" text" VALUE =输入电子邮件 NAME =" userEmail"
| onChange = validateInput()>
| < / form>
| < script type =" text / javascript">
| this.myForm.userEmail.select()
| function validateInput(){
| userInput = this.myForm.userEmail.value
| document.write(userInput)


用alert(userInput)替换上面的行;

| if(userInput.indexOf(''@'')> 0&& userInput.indexOf(''。'')> 0)
|提醒(感谢您的关注。)
|否则
|警告(请在
|提交之前检查您的电子邮件详情是否正确)
| }
| < / script>
| Hi All,
|
| I have this code. When I type in je***@ebay.com, it should run
| alert("Thanks for your interest.") line. But it does not. Why and
| how can I correct it? I use IE 6 with windows xp.
| Thanks a lot.
|
| <HTML><body>
| <form name="myForm">
| <INPUT TYPE="text" VALUE="Enter email" NAME="userEmail"
| onChange=validateInput()>
| </form>
| <script type="text/javascript">
| this.myForm.userEmail.select()
| function validateInput() {
| userInput = this.myForm.userEmail.value
| document.write(userInput)
Replace the above line with alert( userInput );
| if (userInput.indexOf(''@'')>0 && userInput.indexOf(''.'')>0)
| alert("Thanks for your interest.")
| else
| alert("Please check that your email details are correct before
| submitting")
| }
| </script>




----------------------------- ----------------------------------
jn **** @ yourpantsbigpond.net.au :脱掉裤子回复

------------- --------------------------------------------------



---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------


Jenny说:

大家好,

我有这段代码。当我输入 je***@ebay.com 时,它应该运行
警报(感谢您的兴趣。 )行。但事实并非如此。为什么和
如何纠正它?我使用IE 6和windows xp。
非常感谢。

< HTML>< body>
< form name =" myForm">
< INPUT TYPE =" text" VALUE =输入电子邮件 NAME =" userEmail"
onChange = validateInput()>
< / form>
< script type =" text / javascript">
this.myForm .userEmail.select()
函数validateInput(){
userInput = this.myForm.userEmail.value
document.write(userInput)

Hi All,

I have this code. When I type in je***@ebay.com, it should run
alert("Thanks for your interest.") line. But it does not. Why and
how can I correct it? I use IE 6 with windows xp.
Thanks a lot.

<HTML><body>
<form name="myForm">
<INPUT TYPE="text" VALUE="Enter email" NAME="userEmail"
onChange=validateInput()>
</form>
<script type="text/javascript">
this.myForm.userEmail.select()
function validateInput() {
userInput = this.myForm.userEmail.value
document.write(userInput)




此时,您已重新打开当前文档,并将
写入新的HTML。此页面中任何以前存在的HTML

或Javascript代码已被销毁。

任何希望与之前的HTML交互的代码
或Javascript会失败。



At this point, you''ve re-opened the current document and
written new HTML into it. Any previously existing HTML
or Javascript code in this page has been destroyed.
Any code that expects to interact with the previous HTML
or Javascript will fail.


文章< 88 *********************** **@posting.google.com> ,
je ************ @ hotmail.com (Jenny)写道:
In article <88*************************@posting.google.com> ,
je************@hotmail.com (Jenny) wrote:
if(userInput.indexOf(''@'')> 0&& userInput.indexOf(''。'')> 0)
if (userInput.indexOf(''@'')>0 && userInput.indexOf(''.'')>0)




如果您感兴趣,还有更完整的测试来验证电子邮件地址。


请参阅:
http://www.webreference .com / js / tips / 990928.html


Robert



There are more complete tests to verify an email address if you are
interested.

See:
http://www.webreference.com/js/tips/990928.html

Robert


这篇关于indexOf不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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