js form login verification example
Dec 09, 2016 pm 04:08 PMThe example in this article describes the js form login verification method. Share it with everyone for your reference, the details are as follows:
<!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>项目后台管理系统</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); } //验证姓名 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; } } //验证密码 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; } } //验证所有表单提交 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>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Recommended: Excellent JS open source face detection and recognition project

How to use JS and Baidu Maps to implement map pan function

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts

How to create a stock candlestick chart using PHP and JS

How to use JS and Baidu Maps to implement map polygon drawing function

How to use JS and Baidu Map to implement map click event processing function
