PHP
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p> <input type="text" id="name" placeholder="请输入用户名"><a id="a1"></a></p>
<p> <input type="password" id="ps1" placeholder="请输入密码"><a id="a2"></a></p>
<button id="regbtn">注册</button><a id="a3"></a>
<?php
// put your code here
?>
<script src="register.js"></script>
</body>
</html>
JS
function $(id){
return document.getElementById(id);
}
window.onload = function(){
var cname,cps1;
function chk(){
if((cname=='yes')&&(cps1=='yes')){
$('a3').innerHTML="填写成功";
}
}
$('name').οnkeyup=function(){
name=$('name').value;
if(name.length<4){
$('a1').innerHTML="长度不能小于4";
}
else{
$('a1').innerHTML="R";
cname='yes';
}chk();
}
$('ps1').οnkeyup=function(){
ps1=$('ps1').value;
if(ps1.length<4){
$('a2').innerHTML="长度不能小于4";
}
else{
$('a2').innerHTML="R";
cps1='yes';
}chk();
}
}