为什么无法实现页面跳转?

为什么无法实现页面跳转?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<!DOCTYPE html>
<html>
 
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="css/3-10.css">
    <script type="text/javascript" src="js/3-10.js"></script>
</head>
 
<body>
    <!-- 头部 -->
    <header>
        <div class="wrap clearfix">
            <div class="wrap_left">
                <img src="素材/logo.png">
                <span class="wrap_left_1">慕课高铁客户服务中心 | </span>
                <span class="wrap_left_2">客户服务</span>
            </div>
            <div class="wrap_right clearfix">
                <span>意见反馈</span>
                <a href="#" class="high">imooc.com</a>
                <span>&nbsp;&nbsp;您好,请</span>
                <a href="#" class="high shou">登录</a>
                <span class="shou">&nbsp;&nbsp;|&nbsp;&nbsp;注册&nbsp;&nbsp;</span>
                <div class="wrap_right_1 clearfix">
                    <div class="dropdown">
                        <div class="dropdown_1">
                            <span>我的IMOOC</span>
                            <span>▼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        </div>
                        <div class="dropdown_2">
                            <a href="#">未完成订单</a>
                            <a href="#" class="dropdown_2_1">已完成订单(改/退)</a>
                            <a href="#" class="dropdown_2_1">我的保险</a>
                            <a href="#">查看个人信息</a>
                            <a href="#" class="dropdown_2_1">账户安全</a>
                            <a href="#" class="dropdown_2_1">常用联系人</a>
                            <a href="#">重点旅客预约</a>
                            <a href="#" class="dropdown_2_1">遗失物品查找</a>
                            <a href="#" class="dropdown_2_1">服务查询</a>
                            <a href="#">投诉</a>
                            <a href="#">建议</a>
                        </div>
                    </div>
                    <div class="phone shou">
                        <img src="素材/未标题-1.png">
                        <span>手机版</span>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <!-- 主体 -->
    <div class="main">
        <div class="main_wrap">
            <div class="title">
                <span>您现在的位置:</span>
                <span class="sign">客运首页>注册</span>
            </div>
            <div class="info">
                <div class="info_title">账户信息</div>
                <form>
                    <table>
                        <tr>
                            <td class="first"><span class="star">*</span>&nbsp;用&nbsp;户&nbsp;名:</td>
                            <td><input type="text" id="username" placeholder="用户名设置成功后不可修改"></td>
                            <td><span class="col item_">6-30位字母、数字或"_",字母开头</span></td>
                        </tr>
                        <tr>
                            <td><span class="star">*</span>登录密码:</td>
                            <td><input type="password" id="password" placeholder="6-20位字母,数字或符号"></td>
                            <td>
                                <div class="pw pw1"></div>
                                <div class="pw pw2"></div>
                                <div class="pw pw3"></div>
                            </td>
                        </tr>
                        <tr class="col1" id="col1">
                         <td></td>
                         <td><span class="item_"></span></td>
                         <td></td>
                        </tr>
                        <tr>
                            <td><span class="star">*</span>确认密码:</td>
                            <td><input type="password" id="password_check" placeholder="请再次输入密码"></td>
                            <td><span class="item_"></span></td>
                        </tr>
                        <tr class="chinaname">
                            <td><span class="star">*</span>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</td>
                            <td><input type="text" id="ch_name" placeholder="请输入姓名"></td>
                            <td class="chinaname_1">
                                <span class="name_rule col item_">姓名填写规则</span>
                                <div class="name_rules">
                                    1.确认姓名中生僻字无法输入时,可用生僻字拼音或同音字替代。<br>
                                    2.输入姓名保存后,遇有系统无法正确显示的汉字,可用该汉子的拼音或同音字重新修改
                                    后保存。<br>
                                    3.姓名中有繁体字无法输入时,可用简体昔代。<br>
                                    4.姓名较长,汉字与英文字符合计超过30个( 1个汉子算2个字符)的,需按姓名中第一
                                    个汉字或英文字符开始按顺序连续输入30个字符(空格字符不输入) , 其中英文字符输
                                    入时不去别大写
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td><span class="star">*</span>证件类型:</td>
                            <td class="xuan">
                                <select>
                                    <option value="id">身份证</option>
                                    <option value="hz">护照</option>
                                    <option value="tbz">台胞证</option>
                                </select>
                            </td>
                            <td><span></span></td>
                        </tr>
                        <tr>
                            <td><span class="star">*</span>证件号码:</td>
                            <td><input type="text" id="id_number" placeholder="请输入证件号"></td>
                            <td><span class="item_"></span></td>
                        </tr>
                        <tr>
                            <td>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱:</td>
                            <td><input type="email" id="email" placeholder="请输入邮箱"></td>
                            <td><span class="item_"></span></td>
                        </tr>
                        <tr>
                            <td><span class="star">*</span>手机号码:</td>
                            <td><input type="text" id="phone_num" placeholder="请输入手机号码"></td>
                            <td><span class="col item_">请填写手机号码,稍后向该手机号码发送验证码</span></td>
                        </tr>
                        <tr>
                            <td><span class="star">*</span>旅客类型:</td>
                            <td class="xuan">
                                <select>
                                    <option value="cr">成人</option>
                                    <option value="child">儿童</option>
                                    <option value="old">学生</option>
                                    <option value="old">残疾军人</option>
                                    <option value="old">伤残人民警察</option>
                                </select>
                            </td>
                            <td><span></span></td>
                        </tr>
                    </table>
                </form>
                <div class="rule">
                    <input type="checkbox" id="checkbox1">
                    我已阅读并同意遵守
                    <a href="#">《中国铁路客户服务中心网站客户服务条款》</a>
                </div>
                <button id="handup"><a href="javascript:;" id="next">下一步</a></button>
            </div>
        </div>
    </div>
    <!-- 底部 -->
    <footer>
     <div>关于我们|网站声明</div>
     <div class="foot">Copyright &copy; 2017 imooc.com All Rights Reserved|京ICP备 13046642号-2</div>
    </footer>
</body>
 
</html>
 
 
window.onload=function(){
    var userAccount=document.getElementById('username');
    var password=document.getElementById('password');
    var col1=document.getElementById('col1');
    var userPass_=document.getElementById('password_check');
    var items=document.querySelectorAll('.item_');
    var pw=document.querySelectorAll('.pw');
    var userName=document.getElementById('ch_name');
    var information=document.getElementById('id_number');
    var email=document.getElementById('email');
    var telephone=document.getElementById('phone_num');
    var handup=document.getElementById('handup');
    var next=document.getElementById('next');
    var checkBtn=document.getElementById('checkbox1');
    var reg=/正则/;
    var test1=false;
    var test2=false;
    var test3=false;
    var test4=false;
    var test5=false;
    var test6=false;
    var test7=false;
 
// 用户名
userAccount.onblur=function(){
    reg=/^[a-zA-Z]\w{5,29}$/;
    if (this.value==''
    {
        items[0].innerHTML='不能为空';
        items[0].style.color='red';
    }
    else if(!reg.exec(this.value))
    {
        items[0].innerHTML='请输入6-30位数字、字母、_,字母开头';
        items[0].style.color='red';
    }
    else
    {
        items[0].innerHTML='输入正确';
        items[0].style.color='green';
        test1=true;
    }
}
// 密码
password.onblur=function(){
    reg=/^\S{6,20}$/;
    if (this.value==''
    {
        items[1].innerHTML='不能为空';
        items[1].style.color='red';
        col1.style.display='table-row';
    }
    else if(!reg.exec(this.value))
    {
        items[1].innerHTML='6-20位字母,数字或符号';
        items[1].style.color='red';
        col1.style.display='table-row';
 
    }
    // 弱(纯数字、纯字母或者纯符号)
        // else if (/^[1-9]{6-20}$/.exec(this.value)||/^[a-zA-Z]{6-20}$/.exec(this.value)||/^\W{6-20}$/.exec(this.value))
        else if (/^[1-9]{6,20}$/.test(this.value) || /^[a-zA-Z]{6,20}$/.test(this.value) || /^\W{6,20}$/.test(this.value)) {
            items[1].innerHTML = '输入正确';
            items[1].style.color = 'green';
            test2 = true;
            pw[0].style.backgroundColor = 'red';
            pw[1].style.backgroundColor = 'gray';
            pw[2].style.backgroundColor = 'gray';
            col1.style.display = 'table-row';
            console.log('ruo')
  
        }
        // 中(两种类型的结合)
         // else if (/^[1-9|a-z]{6-20}$/i.exec(this.value)||/^[\W|a-z]{6-20}$/i.exec(this.value)||/^[\W|1-9]{6-20}$/i.exec(this.value))
        else if (/^[1-9|a-z]{6,20}$/i.test(this.value) || /^[\W|a-z]{6,20}$/i.test(this.value) || /^[\W|1-9]{6,20}$/i.test(this.value)) {
            items[1].innerHTML = '输入正确';
            items[1].style.color = 'green';
            test2 = true;
            pw[0].style.backgroundColor = 'red';
            pw[1].style.backgroundColor = 'yellow';
            pw[2].style.backgroundColor = 'gray';
            console.log('zhogn ')
        }
        // 强(三种类型的结合)
        // else if (/^(?![a-zA-Z]+$)(?!\d+$)(?![`~!@#$%^&*()_+<>?:"{},.\/;'[\]]+$)(?![a-zA-Z\d]+$)(?![a-zA-Z`~!@#$%^&*()_+<>?:"{},.\/;'[\]]+$)(?![\d`~!@#$%^&*()_+<>?:"{},.\/;'[\]]+$)[a-zA-Z\d`~!@#$%^&*()_+<>?:"{},.\/;'[\]]{6,20}$/) {
        else if (/\W[a-zA-Z]*/.test(this.value)) {
            items[1].innerHTML = '输入正确';
            items[1].style.color = 'green';
            test2 = true;
            pw[0].style.backgroundColor = 'red';
            pw[1].style.backgroundColor = 'yellow';
            pw[2].style.backgroundColor = 'green';
            console.log('qiang')
        }
}
// 确认密码
userPass_.onfocus=function(){
    items[2].innerHTML='请再次输入密码';
    items[2].style.color='green';
}
userPass_.onblur=function(){
    if (this.value=='')
    {
        items[2].innerHTML='再次输入密码不能为空';
        items[2].style.color='red';
    }else{
        if (this.value!=password.value) 
        {
            items[2].innerHTML='两次密码输入不相同';
            items[2].style.color='red';
        }else{
            items[2].innerHTML='再次输入密码正确';
            items[2].style.color='green';
            test3=true;
        }
    }
}
// 姓名
userName.onfocus=function(){
    items[3].innerHTML='请输入姓名';
    items[3].style.color='green';
}
userName.onblur=function(){
    // reg=/^[\w\u4e00-\u9fcc]{3,30}$/;
    reg=/^([a-zA-Z]{3,30}|[\u4e00-\u9fa5]{2,15})$/;
    if (this.value==''
    {
        items[3].innerHTML='不能为空';
        items[3].style.color='red';
    }
    else if(!reg.exec(this.value))
    {
        items[3].innerHTML='姓名只能包含中文或英文,且字符在3-30个之间';
        items[3].style.color='red';
    }
    else
    {
        items[3].innerHTML='输入正确';
        items[3].style.color='green';
        test4=true;
    }
}
// 身份证号码
information.onfocus=function(){
    items[4].innerHTML='请输入身份证号';
    items[4].style.color='green';
}
information.onblur=function(){
    reg=/^\d{17}[0-9x]$/i;
    if (this.value==''
    {
        items[4].innerHTML='不能为空';
        items[4].style.color='red';
    }
    else if(!reg.exec(this.value))
    {
        items[4].innerHTML='请输入18位身份证号';
        items[4].style.color='red';
    }
    else
    {
        items[4].innerHTML='输入正确';
        items[4].style.color='green';
        test5=true;
    }
}
// email
email.onfocus=function(){
    items[5].innerHTML='请输入正确邮箱格式';
    items[5].style.color='green';
}
email.onblur=function(){
     
    reg=/^\w+@\w+\.+[a-zA-Z_]{2,4}$/;
    if (this.value==''
    {
        items[5].innerHTML='不能为空';
        items[5].style.color='red';
    }
    else if(!reg.exec(this.value))
    {
        items[5].innerHTML='请输入正确邮箱格式';
        items[5].style.color='red';
    }
    else
    {
        items[5].innerHTML='输入正确';
        items[5].style.color='green';
        test6=true;
    }
}
// 手机号码
telephone.onfocus=function(){
    items[6].innerHTML='请输入您的手机号码';
    items[6].style.color='green';
}
telephone.onblur=function(){
     
    reg=/^1[0,3,4,5,6,7,8,9]\d{9}$/;
    if (this.value==''
    {
        items[6].innerHTML='不能为空';
        items[6].style.color='red';
    }
    else if(!reg.exec(this.value))
    {
        items[6].innerHTML='请输入正确手机号';
        items[6].style.color='red';
    }
    else
    {
        items[6].innerHTML='输入正确';
        items[6].style.color='green';
        test7=true;
    }
}
 
// 提交按钮
handup.onclick=function(){
    if (test1==false||test2==false||test3==false||test4==false||test5==false||test6==false||test7==false||checkBtn.checked==false
    {
        // next.href='#';
        alert('请完善信息');
    }else{
        window.event.returnValue=false;
        next.href='https://www.imooc.com';
         
    }
}
}
 
 
*{
    margin: 0;
    padding: 0;
}
.clearfix:after {
content:".";
display:block;
height: 0;
visibility: hidden;
clear:both;
}
.clearfix {zoom:1;}
a{
    text-decoration: none;
}
body{
    min-width: 1200px;
}
/* 头部 */
header{
    height: 130px;
    background: #eee;
}
.shou{
    cursor: pointer;
}
.wrap{
    width: 1200px;
    margin: 0 auto;
    height: 130px;
}
.wrap_left{
    height: 130px;
    line-height: 130px;
    float: left;
}
.wrap_left img{
    vertical-align: middle;
    cursor: pointer;
}
.wrap_left span.wrap_left_1{
    font-size: 20px;
    font-weight: bold;
}
.wrap_left span.wrap_left_2{
    font-size: 15px;
    color: gray;
}
.wrap_right{
    float: right;
    height: 130px;
    line-height: 130px;
    font-size: 15px;
}
.wrap_right a.high{
    color: rgb(251, 116, 3);
}
.wrap_right_1{
    float: right;
    position: relative;
}
.dropdown{
    float: left;
}
.dropdown_1{
    cursor: pointer;
}
.dropdown_2{
    width: 200px;
    height: 330px;
    line-height: 30px;
    border: 1px solid rgb(251, 116, 3);
    padding: 20px;
    position: absolute;
    top: 80px;
    left: 0;
    background-color: white;
    display: none;
}
.dropdown_1:hover~.dropdown_2{
    display: block;
}
.dropdown_2:hover{
    display: block;
 
}
.dropdown_2 a{
    display: block;
    color: gray;
}
a.dropdown_2_1{
    border-bottom: 1px dashed gray;
}
.dropdown_2 a:hover{
    color: rgb(251, 116, 3);
}
.phone{
    float: right;
}
.phone img{
    width: 20px;
    height: 30px;
    vertical-align: middle;
}
/* 主体 */
.main{
    width: 100%;
    height: 1000px;
    border-bottom: 2px solid rgb(36,135,201);
    border-top: 2px solid rgb(36,135,201);
}
.main_wrap{
    width:1200px;
    margin: 0 auto;
    font-size: 15px;
}
.title{
    margin-top: 20px;
    margin-bottom: 20px;
}
.sign{
    color: gray;
}
.info{
    width: 100%;
    height: 800px;
    border: 1px solid rgb(251, 116, 3);
    border-radius: 20px;
}
.info_title{
    width: 100%;
    height: 80px;
    background-color: rgb(251, 116, 3);
    color: white;
    border-radius: 20px;
    padding-left: 30px;
    line-height: 80px;
    box-sizing: border-box;
    font-size: 20px;
}
.star{
    color: rgb(251, 116, 3);
}
form{
    margin-top: 70px;
    margin-left: 300px;
    line-height: 40px;
}
td.xuan{
    width: 218px;
}
select{
    width: 220px;
}
tr td:first-child{
    width: 120px;
    text-align: right;
    padding-right: 20px;
}
tr td:nth-child(2){
    width: 250px;
}
div.rule{
    margin-left: 415px;
}
.pw{
    width: 40px;
    height: 10px;
    margin-right: 5px;
    float: left;
}
.pw1{
    background-color: red;
}
.pw2{
    background-color: gray;
}
.pw3{
    background-color: gray;
}
.col{
    color: rgb(251, 116, 3);
}
tr.chinaname{
    position: relative;
}
div.name_rules{
    position: absolute;
    width: 500px;
    height: 300px;
    border: 1px solid rgb(36,135,201);
    top: 500px;
    left: 1050px;
    display: none;
    padding: 10px;
    background-color: white;
}
.chinaname_1{
    cursor: pointer;
}
.chinaname_1:hover .name_rules{
    display: block;
}
button{
    width: 150px;
    height: 60px;
    background-color: rgb(251, 116, 3);
    border: none;
    border-radius: 10px;
    margin-left: 600px;
    margin-top: 80px;
}
button a{
    color: white;
}
#col1{
    color: red;
    display: none;
}
/* 底部 */
footer{
    width: 100%;
    height: 100px;
    background-color: #eee;
    color: gray;
    font-size: 15px;
    text-align: center;
    padding-top: 20px;
    box-sizing: border-box;
}
.foot{
    margin-top: 20px;
}


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

你好,是因为写了禁止提交的代码:

http://img1.sycdn.imooc.com//climg/5cf75ef90001c81a08230334.jpg    

去掉就可以了,自己测试下。

祝学习愉快!

  • 感谢老师,请问为什么点击按钮一次不会实现跳转,要点好几次才能实现跳转?
    2019-06-11 10:14:26
  • 你好,这边使用Chrome浏览器进行测试,将表单填写完之后点击一次按钮就可以跳转哦,建议重新测试或者更换浏览器测试下。
    2019-06-11 11:50:36
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
组件化思想开发电商网页 18版
  • 参与学习           人
  • 提交作业       467    份
  • 解答问题       4826    个

本路径带你通过系统学习HTML5、JavaScript、jQuery的进阶知识,不仅如此,还会学习如何利用组件化的思想来开发网页,知识点+案例,使得所学可以更好的得到实践。

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码