首页 新闻 搜索 专区 学院

javascript无响应

0
悬赏园豆:20 [待解决问题] 解决于 2011-09-04 20:31
1 <html>
2 <head>
3 <title>登录</title>
4 <link rel="stylesheet" type="text/css" href="register.css" />
5 <script language="javaScript">
6 function check()
7 {
8 var name = document.form1.name.value;
9 var password = document.form1.passWord.value;
10 var password2 = document.form1.passWord2.value;
11 var tel = document.form1.tel.value;
12 var email = document.form1.email.value;
13
14 if (name==""|| password==""||tel==""||email==""||safeanswer==""||password2=="")
15 {
16 alert("任意信息不能为空,请重新填写!");
17 return false;
18 }
19 else if(name.length> 12){
20 alert("用户名不能超过12个字符,请重新输入!");
21 return false;
22 }
23 else if(password.length<6){
24 alert("密码不能小于6个字符,请重新输入!");
25 return false;
26 }
27 else if (password!=password2)
28 {
29 alert("2次密码输入不一致!");
30 return false;
31 }
32 else if(tel.length > 20)
33 {
34 alert("联系方式长度不能超过20字符!");
35 return false;
36 }
37 else if (isNaN(tel))
38 {
39 alert("联系方式必须是数字");
40 return false;
41 }
42 else if (
43 email.length== 0 ||
44 email.charAt(0)=="." ||
45 email.charAt(0)=="@"||
46 email.indexOf('@', 0) == -1 ||
47 email.indexOf('.', 0) == -1 ||
48 email.lastIndexOf("@")==email.length-1 ||
49 email.lastIndexOf(".")==email.length-1)
50 {
51 alert("Email地址格式不正确!");
52
53 return false;
54 }
55
56 else{
57 return true;
58 }
59
60 }
61 function reset()
62 {
63 var r=confirm("确定重置?");
64 if (r==true)
65 {
66 alert("已重置!");
67 }
68 else
69 {
70 alert("请继续!");
71 }
72
73
74 }
75 </script>
76 </head>
77 <body>
78 <div id="formwrapper">
79 <h3>&nbsp;</h3>
80 <br/>
81 <form id=form1 name="form1" method = "post" action = "" onSubmit="return check()">
82 <fieldset>
83 <legend>新用户注册</legend>
84 <p><strong>我们保证您的信息不会被公布出去,请您如实填写.</strong></p>
85 <p>在您注册之前请先认真阅读服务条款.</p>
86
87 <div>
88 <label for="name">姓名</label>
89 <input type="text" name="name" class="input" id="name" size="20" maxlength="12" />
90 *(最多12个字符)<br/>
91 </div>
92
93 <div>
94 <label for="password">密码</label>
95 <input type="password" name="password" class="input" id="password" size="18" maxlength="15" />
96 *(最多15个字符)<br/>
97 </div>
98 <div>
99 <label for="password2">重复密码</label>
100 <input type="password" name="password2" class="input" id="password2" size="18" maxlength="15" />
101 *<br/>
102 </div>
103 <div>
104 <label for="tel">电话</label>
105 <input type="text" name="tel" class="input" id="tel" size="20" maxlength="20" />
106 *(请如实填写)<br/>
107 </div>
108 <div>
109 <label for="safequestion">密码保护问题</label>
110 <select name="safequestion" id="safe">
111 <option value="公司">您的公司所在城市?</option>
112 <option value="家乡">您的家乡所在省份?</option>
113 <option value="院校">您的毕业院校?</option>
114 </select>
115 *<br/>
116 </div>
117 <div>
118 <label for="safeanswer">密码保护答案</label>
119 <input type="text" name="safeanswer" id="answer" class="input" size="20" maxlength="150"/>
120 *<br/>
121 </div>
122 <div>
123 <label for="email">电子邮箱</label>
124 <input type="text" name="email" class="input"
125 id="email" size="20" maxlength="150" />
126 *<br/>
127 </div>
128 <div>
129 <label for="AgreeToTerms">同意服务条款</label>
130 <input type="checkbox" name="AgreeToTerms" id="AgreeToTerms" value="1" />
131 <a href="#" title="您是否同意服务条款">先看看条款?</a> * </div>
132 <div class="enter">
133 <input name="create791" type="submit" class="buttom" value="提交" />
134 <input name="Submit" type="reset" class="buttom" value="重置" onClick="reset()" />
135 </div>
136 <br/>
137 </fieldset>
138 </form>
139 <br/>
140 <h2>Small Birds</h2>
141 </div>
142 </body>
143 </html>
iceloon的主页 iceloon | 初学一级 | 园豆:180
提问于:2011-08-05 20:31
< >
分享
所有回答(4)
0

var password = document.form1.passWord.value;

红色字体部分写错

lucika.china | 园豆:25 (初学一级) | 2011-08-05 21:33
0

  9      var password = document.form1.passWord.value;
10      var password2 = document.form1.passWord2.value;

应该是:

var password = document.form1.password.value;
var password2 = document.form1.password2.value;



人间烟火 | 园豆:20 (初学一级) | 2011-08-05 22:03
0

建议用个浏览器通用的方法  document.getElementById('元素ID').value='值'

慧☆星 | 园豆:5555 (大侠五级) | 2011-08-06 09:06
0

你这个doucument.form1这种写法貌似不能浏览器通用。

顾晓北 | 园豆:10790 (专家六级) | 2011-08-06 13:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册