/*-------省略部分代码---------*/
<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>
回复讨论(解决方案)
Statement: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