js實現登陸介面

來源:互聯網
上載者:User

標籤:

代碼分享:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
input[type]{
border: 1px solid darkorange;
background: white;
}
#button{
border: 10px solid orange;
width: 200px;
box-shadow:0px 4px 5px #666;
background: orange;
color: white;
}
</style>
</head>
<body>
<center>
<div>
<form>
<h3>使用者註冊</h3>
<hr>
<p>使用者名稱:<input type="text" id="name" placeholder="請填寫使用者名稱" required="required" onblur="name1()" <!--onfocus="name2()-->"><br><span id="tel"></span></p>
<p>密碼:<input id="paswd" type="password" placeholder="請填寫密碼" onblur="pwd1()" required="required" onfocus="pwd2()"><br><span id="pw"></span></p>
<p>確認密碼:<input id="paswd2" type="password" placeholder="請確認密碼" required="required" onkeyup="validate()" ><br><span id="qpwtx"></span></p>
<p>郵箱:<input type="email" placeholder="請填寫郵箱" required="required"></p>
<p><input type="checkbox" required="required">我已閱讀註冊手冊</p>
<p><input type="submit" id="button" value="註冊"></p>
</form>
</div>
</center>
</body>
<script>
function name1(){
var name=document.getElementById("name").value;
if(name.length==""){
document.getElementById("tel").innerHTML="使用者名稱不可為空"
document.getElementById("tel").style.color="red";
}else{
document.getElementById("tel").innerHTML="√"
document.getElementById("tel").style.color="green";
}
}
function pwd2(){
document.getElementById("pw").innerHTML="請填寫6-12位的密碼"
document.getElementById("pw").style.color="#999";

}
function pwd1(){
p=document.getElementById("paswd").value;

if(p.length>=6&&p.length<=20)
{
document.getElementById("pw").innerHTML="√"
document.getElementById("pw").style.color="green";
}else{
document.getElementById("pw").innerHTML="格式錯誤,請輸入6-20位"
document.getElementById("pw").style.color="red";
}
}
function validate(){
var qpw=document.getElementById("paswd").value;
var qpw2=document.getElementById("paswd2").value;

if(qpw==qpw2 && p.length>=6&&p.length<=20){
document.getElementById("qpwtx").innerHTML="<font color=‘green‘>√</font>";
document.getElementById("button").disabled = false;
}
else {
document.getElementById("qpwtx").innerHTML="<font color=‘red‘>兩次密碼不相同或者格式錯誤</font>";
document.getElementById("button").disabled = true;
}
}
</script>
</html>

效果:

js實現登陸介面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.