Discuss / JavaScript / 交作业

交作业

Topic source

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

 var name_1 = document.getElementById('username');

    var pas_1 = document.getElementById('password');

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

    var reg1 = /[0-9a-zA-Z\_]{3,10}/;

    var reg2 = /[\S]{6,20}/;

   if(!reg1.test(name_1.value)){

    window.alert('用户名输入错')

    return false;

   }

   if(!reg2.test(pas_1.value)){

    window.alert('密码输入错')

    return false;

   }

   if(pas_1.value !== pas_2.value){

   window.alert('两次密码不一致');

   return false;

}


  • 1

Reply