完成登錄與注冊(cè)頁(yè)面的HTML+CSS+JS,其中的輸入項(xiàng)檢查包括:
成都創(chuàng)新互聯(lián)是一家朝氣蓬勃的網(wǎng)站建設(shè)公司。公司專(zhuān)注于為企業(yè)提供信息化建設(shè)解決方案。從事網(wǎng)站開(kāi)發(fā),網(wǎng)站制作,網(wǎng)站設(shè)計(jì),網(wǎng)站模板,微信公眾號(hào)開(kāi)發(fā),軟件開(kāi)發(fā),小程序開(kāi)發(fā),十余年建站對(duì)成都VR全景等多個(gè)領(lǐng)域,擁有豐富的網(wǎng)站運(yùn)維經(jīng)驗(yàn)。
用戶名6-12位
首字母不能是數(shù)字
只能包含字母和數(shù)字
密碼6-12位
注冊(cè)頁(yè)兩次密碼是否一致
html代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>歡迎你,請(qǐng)先登陸!</title> <script type="text/javascript" src="../static/jsp/lx.js"></script> <link rel="stylesheet"> <link rel="stylesheet" href="../static/css/lx.css"> </head> <body> <div class="box"> <h3>登陸</h3> <div class="input_box"> <input id="uname" type="text" name="user" placeholder="請(qǐng)輸入用戶名"> </div> <div class="input_box"> <input id="upass" type="password" name="psw" placeholder="請(qǐng)輸入密碼"> </div> <div id="error_box"><br></div> <div class="input_box"> <button type="button" class="btn btn-primary" onclick="fnLogin()">登陸</button>     <a href="regist.html"><input type="button" class="btn btn-info" name="regist" value="注冊(cè)"></a> </div> </div> </body> </html>
css代碼:
*{ margin: 0; padding: 0; font-family: 微軟雅黑; font-size: 12px; } .box{ width: 390px; height: 320px; border: solid 1px #ddd; background: #FFF; position: absolute; left: 50%; top:42%; margin-left: -195px; margin-top: -160px; text-align: center; } .box h3{ font-weight: normal; color:#666; font-size: 16px; line-height: 40px; overflow: hidden; text-align: center; border-bottom: solid 1px #ddd; background: #f7f7f7; } .input_box{ width:350px; padding-bottom: 15px; margin: 0 auto; overflow: hidden; }
javascript代碼:
function fnLogin() { var oUname = document.getElementById("uname") var oUpass = document.getElementById("upass") var oError = document.getElementById("error_box") var isError = true; if (oUname.value.length > 20 || oUname.value.length < 6) { oError.innerHTML = "用戶名請(qǐng)輸入6-20位字符"; isError = false; return; }else if((oUname.value.charCodeAt(0)>=48) && (oUname.value.charCodeAt(0)<=57)){ oError.innerHTML = "首字符必須為字母"; return; }else for(var i=0;i<oUname.value.charCodeAt(i);i++){ if((oUname.value.charCodeAt(i)<48)||(oUname.value.charCodeAt(i)>57) && (oUname.value.charCodeAt(i)<97)||(oUname.value.charCodeAt(i)>122)){ oError.innerHTML = "必須為字母跟數(shù)字組成"; return; } } if (oUpass.value.length > 20 || oUpass.value.length < 6) { oError.innerHTML = "密碼請(qǐng)輸入6-20位字符" isError = false; return; } window.alert("登錄成功") }
注冊(cè)界面html代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>歡迎你,請(qǐng)先登陸!</title> <script type="text/javascript" src="../static/jsp/lx.js"></script> <link rel="stylesheet"> </head> <body> <div id="container" align="center"> <div id="header" > <h3 align="center">注冊(cè)</h3> </div> <div id="content"> <p align="center">賬號(hào): <input id="uname" type="text" name="user" placeholder="賬號(hào)首字符為字母"> </p> <p align="center">密碼: <input id="upass" type="password" name="psw" placeholder="請(qǐng)輸入密碼"> </p> <div id="error_box"><br></div> <br> <button onclick="fnLogin()" class="btn btn-info">注冊(cè)</button> </div> <div > <i>版權(quán)信息@</i> </div> </div> </body> </html>
運(yùn)行結(jié)果如下:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
網(wǎng)頁(yè)標(biāo)題:js實(shí)現(xiàn)登錄與注冊(cè)界面
本文地址:http://chinadenli.net/article0/jiieio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、、商城網(wǎng)站、微信公眾號(hào)、定制網(wǎng)站、自適應(yīng)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)