Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 JavaScript问题。
jasonwing27





发贴: 66
积分: 0
于 2006-03-11 19:27 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java"%>
<html>
<head>
<title>用户注册页面--[login_in.jsp]</title>
</head>

<!--JavaScript验证输入-->
<script language="JavaScript">
function check()
{
fr = document.form1 ;

//用户名称验证。
  if(fr.userName.value=="")//用户名不能为空
  {
    alert("用户ID必须要填写!");
    fr.uid.focus();
    return;
  }

//密码验证。
if((fr.userPassword.value != "") || (fr.userPassword1.value != ""))//两次密码输入必须一致
  {
    if(fr.userPassword.value!=fr.userPassword1.value)
    {
      alert("密码不一致,请重新输入并验证密码!");
      fr.userPassword.focus();
      return;
    }
  }
  else {//密码也不能为空
    alert("密码不能为空!");
    fr.userPassword.focus();
    return;
  }

//昵称验证。
if(fr.nickName.value == "")//昵称不能为空
  {
    alert("昵称必须要填写!");
    fr.nickName.focus();
    return;
  }

//真实姓名验证。
if(fr.realName.value == "")//真实姓名不能为空
  {
    alert("真实姓名必须要填写!");
    fr.realName.focus();
    return;
  }

//性别验证。
if(fr.gender.value == "")//性别必须填写
  {
    alert("性别必须要填写!");
    fr.gender.focus();
    return;
  }

//电子邮件验证。
if(fr.email.value != "")//验证email的格式
  {
    if(!isEmail(fr.email.value)) {
      alert("请输入正确的信箱名称!");
      fr.email.focus();
      return;
    }
  }
  fr.submit();
}

function isEmail(theStr){
var atindex=theStr.indexOf('@');
var dotindex=theStr.indexOf('.',atindex);
var flag=true;
thesub=theStr.substring(0,dotindex+1);
if((atindex<1)||(atindex!=theStr.lastIndexOf('@'))||(dotindex<atindex+2)||(theStr.length<=thesub.length)){
flag=false;
}else{
flag=true;
}
return(flag);
}
</script>
<body>

<!--注册表单-->
<div align="center">
<h2>用户资料录入</h2>
<h4>*号项为必填内容</h4>
<hr>
<form name="form1" id="form1" method="post" action="login_check.jsp">

<p>用户名称:<input type="text" name="userName"/>*
<p>用户密码:<input type="password" name="userPassword"/>*
<p>验证密码:<input type="password" name="userPassword1"/>*
<p>用户昵称:<input type="text" name="nickName"/>*
<p>真实姓名:<input type="text" name="realName"/>*
<p>用户性别:  <input type="radio" name="gender" value="man" checked="checked"/>男
<input type="radio" name="gender" value="women"/>女  *
<p>电子邮件:<input type="text" name="email"/>*
<p>联系地址:<input type="text" name="address"/>
<p>联系电话:<input type="text" name="tel"/>
<hr>
<p><input type="submit" value="提交" name="B1">
       
<input type="reset" value="重置" name="B2"></p>

</form>
<!--表单结束-->
</div>
</body>
</html>



作者 Re:JavaScript问题。 [Re:jasonwing27]
hitaco





发贴: 432
积分: 31
于 2006-03-11 21:14 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你想问什么?


作者 Re:JavaScript问题。 [Re:jasonwing27]
RingofAngel





发贴: 15
积分: 0
于 2006-03-14 11:14 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<form name="form1" id="form1" method="post" onSubmit = "check()">

fr.action = "login_check.jsp";
fr.submit();



作者 Re:JavaScript问题。 [Re:jasonwing27]
jackyangf





发贴: 58
积分: 1
于 2006-03-21 17:15 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
check()函数没有调用
login_check.jsp?



作者 Re:JavaScript问题。 [Re:jasonwing27]
tuncan





发贴: 1
积分: 0
于 2006-04-18 10:44 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不明白


作者 Re:JavaScript问题。 [Re:jasonwing27]
769777438





发贴: 4
积分: 0
于 2008-09-09 08:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在表单提交的时候应该是这样的吧
submit="return check()"



作者 Re:JavaScript问题。 [Re:jasonwing27]
scottding

十三部落酋长

CJSDN高级会员


发贴: 1054
积分: 101
于 2008-09-09 10:35 user profilesend a private message to usersend email to scottdingsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
看到这个帖子我就晕了,一大早就云里雾里。

What are you talking about?What are you talking about?What are you talking about?



Blog   Home   @unumu

作者 Re:JavaScript问题。 [Re:jasonwing27]
maoyuanbo





发贴: 5
积分: 0
于 2009-04-20 19:47 user profilesend a private message to usersend email to maoyuanbosearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
fr.uid.focus();
我好像没有看到有这个控件啊



作者 Re:JavaScript问题。 [Re:jasonwing27]
maoyuanbo





发贴: 5
积分: 0
于 2009-04-20 19:49 user profilesend a private message to usersend email to maoyuanbosearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
return(flag);
这个为什么要这样写的



作者 Re:JavaScript问题。 [Re:jasonwing27]
loverinfiner





发贴: 5
积分: 0
于 2009-05-05 13:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<input type="submit" value="提交" name="B1" onclick="check()">
应该能行,
最好用type="button" 好一点




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923