javascriptフォームアカウントのパスワードチェック提出
1618 ワード
Document
/*
:
from
action url ,
method get post
:get sucess.html?username='lili'&pwd='1231'
post sucess.html
submit
onsubmit return ; true ""
:
*/
//
var iptName=document.getElementById('txt-name');
var iptPwd=document.getElementById('pwd');
var tipName=document.getElementById('tip-name');
var tipPwd=document.getElementById('tip-pwd');
//
function valForm(){
return valUserName()&&valPwd();
}
//
function valUserName() {
var p=/^\w\w{7,11}$/;// 8-12
var r=p.test(iptName.value);//
if(!r){
//
tipName.style.display='inline-block';//
iptName.focus();
return false;
}
return true;
}
//
function valPwd(){
var p=/^\d\d{5}$/;//6
var r=p.test(iptPwd.value);//
if(!r){
tipPwd.style.display='inline-block';
iptPwd.focus();//
return false;
}
return true;
}