没有很多内容,就是随笔,这个验证大都是用ajax做的毕竟要和服务器交互。
<html>
<head>
<title>账号是否已经存在练习</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312"/>
<style type="text/css">
</style>
</head>
<body>
<!--onkeyup是一种键盘事件-->
<input type="text" id="username" placeholder="输入账号" οnkeyup="check()"/>
<span id="sp"></span>
<script>
function check(){
var username = document.getElementById("username");
var sp = document.getElementById("sp");
if(username.value.length>=6){
sp.innerHTML = "账号密码可用";
document.getElementById("sp").style.color="green";
}else{
document.getElementById("sp").style.color="red";
sp.innerHTML = "账号密码不可用";
}
}
</script>
</body>
</html>