js表單登陸驗(yàn)證示例
本文實(shí)例講述了js表單登陸驗(yàn)證的方法。分享給大家供大家參考,具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>項(xiàng)目后臺(tái)管理系統(tǒng)</title> <link rel="stylesheet" href="__PUBLIC__/css/login.css" /> <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script> <script type="text/javascript"> function $(id) { return document.getElementById(id); } //驗(yàn)證姓名 function checkname(){ var name=$("admin_name").value; if(name=='') { $('s1').innerHTML='姓名不能為空'; $('s1').style.color='red'; return false; } else { $('s1').innerText='ok'; $('s1').style.color='green'; return true; } } //驗(yàn)證密碼 function checkpwd(){ var password=$("password").value; if(password=='') { $('s2').innerHTML='密碼不能為空'; $('s2').style.color='red'; return false; } else { $('s2').innerHTML='ok'; $('s2').style.color='green'; return true; } } //驗(yàn)證所有表單提交 function checkall() { if(checkname()&&checkpwd()) { return true; } else { return false; } } </script> </head> <body class="b"> <div class="lg"> <form action="__URL__/dologin" method="POST" onsubmit="return checkall();"> <div class="lg_top"></div> <div class="lg_main"> <div class="lg_m_1"> <input name="admin_name" value="" class="ur" id="admin_name" onblur="checkname();"/><span id='s1'></span> <input name="password" type="password" value="" class="pw" id="password" onblur="checkpwd();"/><span id='s2'></span> </div> </div> <div class="lg_foot"> <input type="submit" value="Login In" class="bn" /></div> </form> </div> </body> </html>
更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript查找算法技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》、《JavaScript中json操作技巧總結(jié)》、《JavaScript切換特效與技巧總結(jié)》、《JavaScript動(dòng)畫(huà)特效與技巧匯總》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)》
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
- jquery css實(shí)現(xiàn)郵箱自動(dòng)補(bǔ)全
- Java實(shí)現(xiàn)郵箱找回密碼實(shí)例代碼
- 如何驗(yàn)證會(huì)員系統(tǒng)中用戶的郵箱是否真實(shí)存在
- 在js中實(shí)現(xiàn)郵箱格式的驗(yàn)證方法(推薦)
- jQuery驗(yàn)證手機(jī)號(hào)郵箱身份證的正則表達(dá)式(含港澳臺(tái))
- jQuery實(shí)現(xiàn)郵箱下拉列表自動(dòng)補(bǔ)全功能
- 微信小程序-詳解微信登陸、微信支付、模板消息
- JavaWeb登陸功能實(shí)現(xiàn)代碼
- php實(shí)現(xiàn)登陸模塊功能示例
- 用AJAX實(shí)現(xiàn)頁(yè)面登陸以及注冊(cè)用戶名驗(yàn)證的簡(jiǎn)單實(shí)例
- 根據(jù)輸入郵箱號(hào)跳轉(zhuǎn)到相應(yīng)登錄地址的解決方法
相關(guān)文章
JS實(shí)現(xiàn)購(gòu)物車中商品總價(jià)計(jì)算
這篇文章主要為大家詳細(xì)介紹了JS實(shí)現(xiàn)購(gòu)物車中商品總價(jià)的計(jì)算 ,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-03-03javascript實(shí)現(xiàn)可鍵盤(pán)控制的抽獎(jiǎng)系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了javascript實(shí)現(xiàn)可鍵盤(pán)控制的抽獎(jiǎng)系統(tǒng)的相關(guān)資料,需要的朋友可以參考下2016-03-03js實(shí)現(xiàn)表單檢測(cè)及表單提示的方法
這篇文章主要介紹了js實(shí)現(xiàn)表單檢測(cè)及表單提示的方法,涉及javascript表單元素提示效果的相關(guān)技巧,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下2015-08-08js實(shí)現(xiàn)的仿新浪微博完美的時(shí)間組件升級(jí)版
本博客沒(méi)有華麗的布局,只求樸實(shí)的js的代碼,只為js代碼愛(ài)好者提供,一周大概會(huì)出1-2篇js前沿代碼的文章.只是代碼,不說(shuō)技術(shù)2011-12-12