为什么我写的js代码没有起作用

WBOY
Release: 2016-06-23 13:57:25
Original
1391 people have browsed it














" id="username" class="input-text1"/>
" id="pwd" class="input-text1"/>
" id="repwd" class="input-text1"/>
" id="email" class="input-text1"/>

     
" id="QQ" class="input-text1"/>
" id="homepage" class="input-text1"/>
" id="birth" class="input-text1"/>
" id="city" class="input-text1"/>
" id="adr" class="input-text1"/>






 

/*-------省略部分代码---------*/
<script> <br /> String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g, '');} <br /> function do_submit() { <br /> var username = document.getElementById('username'); <br /> if ( username.value.trim() == '' ) { <br /> window.alert('用户名尚未填写。'); <br /> username.className = 'input-error'; //设置CSS样式 <br /> username.focus(); //聚焦 <br /> username.value = ''; <br /> return false; //阻止表单提交 <br /> } <br /> <br /> var pwd = document.getElementById('pwd'); <br /> if ( pwd.value.trim() == '' ) { <br /> window.alert('密码尚未填写。'); <br /> pwd.className = 'input-error'; <br /> pwd.focus(); <br /> pwd.value = ''; <br /> return false; <br /> } <br /> //window.alert(passwd.value.trim().length); <br /> if ( pwd.value.trim().length < 6 ) { <br /> window.alert('密码不能少于六位!'); <br /> pwd.className = 'input-error'; <br /> pwd.focus(); <br /> pwd.value = ''; <br /> return false; <br /> } <br /> <br /> var repwd = document.getElementById('repwd'); <br /> if ( repwd.value.trim() == '' ) { <br /> window.alert('重复密码尚未填写。'); <br /> repwd.className = 'input-error'; <br /> repwd.focus(); <br /> repwd.value = ''; <br /> return false; <br /> } else { <br /> if ( pwd.value.trim() != repwd.value.trim() ) { <br /> window.alert('两次密码不一致!'); <br /> return false; <br /> } <br /> } <br /> <br /> var email = document.getElementById('email'); <br /> if ( email.value.trim() == '' ) { <br /> window.alert('电子邮件尚未填写。'); <br /> email.className = 'input-error'; <br /> email.focus(); <br /> email.value = ''; <br /> return false; <br /> } <br /> </script>


回复讨论(解决方案)



==》

 结尾少个}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!