var user_name = document.getElementById('username').value; var input_password = document.getElementById('password').value; var confirm_password = document.getElementById('password-2').value; var error = document.getElementById('test-error'); error.innerText = ''; console.log('user_name: ' + user_name); console.log('input_password: ' + input_password); console.log('confirm_password: ' + confirm_password); var re_username = /^[a-zA-Z0-9]{3,10}$/; var re_password = /^.{6,20}$/; if(!re_username.test(user_name)) { error.innerText = '用户名必须是3-10位英文字母或数字'; return false; } if(!re_password.test(input_password)) { error.innerText = '口令必须是6-20位'; return false; } if(input_password !== confirm_password) { error.innerText = '两次输入口令必须一致'; return false; } return true;
Sign in to make a reply
思想上的小丸子