Discuss / JavaScript / 交作业

交作业

Topic source

L__miracle

#1 Created at ... [Delete] [Delete and Lock User]

var uvalue= document.getElementById('username').value;

var passwordvalue = document.getElementById('password').value;

var passwordvalue2= document.getElementById('password-2').value;

var error = document.getElementById('test-error');

var root_username = /^[a-zA-Z0-9]{3,10}$/;

var root_password = /^.{6,20}$/;

if(!root_username.test(uvalue)) { error.innerText = '用户名必须是3-10位英文字母或数字';return false;}

if(!root_password.test(passwordvalue )) { error.innerText = '口令必须是6-20位';return false;}if(passwordvalue !== passwordvalue2) {error.innerText = '两次输入口令必须一致';return false;}return true;}


  • 1

Reply