javascript 登陆界面代码
Javascript弹窗代码大全(收集)
弹窗代码大全(收集)以下包括强制弹窗 24小时IP弹窗延时弹窗退弹等我们使用cookie来控制一下就可以了。
首先,将如下代码加入主页面html的<head>区:<script>function openwin(){window.open(”page.html”,”",”width=200,height=200″)}function get_cookie(name){var search = name + “=”var returnvalue = “”;if (documents.cookie.length > 0) {offset = documents.cookie.indexof(search)if (offset != -1) {offset += search.lengthend = documents.cookie.indexof(”;”, offset);if (end == -1)end = documents.cookie.length;returnvalue=”/unescape(documents.cookie.substring(offset,end))”}}return returnvalue;}function loadpopup(){if (get_cookie(’popped’)==”){openwin()documents.cookie=”popped=yes”}}</script>然后,用<body onload=”loadpopup()”>(注意不是openwin而是loadpop啊!)替换主页面中原有的<body>这一句即可。
你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。
真正的pop-only-once!写到这里弹出窗口的制作和应用技巧基本上算是完成了,俺也累坏了,一口气说了这么多,希望对正在制作网页的朋友有所帮助俺就非常欣慰了。
学生登陆界面源代码
<%@page contentType="text/html;charset=utf-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>学生登陆</title><style type="text/css"><!--#Layer1 {position:absolute;width:625px;height:29px;z-index:1;left: 333px;top: 71px;}.STYLE1 {font-size: 60px;color: #5D4328;}#Layer2 {position:absolute;width:268px;height:30px;z-index:2;left: 16px;top: 23px;}#Layer3 {position:absolute;width:200px;height:43px;z-index:3;left: 481px;top: 213px;}.STYLE3 {font-size: 62px}.STYLE4 {font-size: 24px}#Layer4 {position:absolute;width:329px;height:168px;z-index:3;left: 446px;top: 190px;}#Layer5 {position:absolute;width:200px;height:115px;z-index:3;left: 602px;top: 304px;}#Layer6 {position:absolute;width:391px;height:261px;z-index:3;left: 342px;top: 205px;}#Layer7 {position:absolute;width:207px;height:170px;z-index:4;left: 657px;top: 301px;}.STYLE5 {font-size: 24px;color: #996600;font-weight: bold;}.STYLE8 {font-size: 14px; }--></style><script type="text/javascript" src="../js/jquery-1.4.3.js"></script> <script type="text/javascript" >//标识各项是否通过var flag={"name":false,"password":false};$(function(){//用户email非空,格式检查$('#txtStudentname').blur(function(){$(this).html("");var emailTXT=$('#txtStudentname').val().trim();if(emailTXT==""){$("#name\\.info").html("name地址不能为空");return;}flag.email=true;$("#name\\.info").html("<imgsrc='../image/label3_s.gif'/>");});});//密码项:非空,长度6-20字符$(function(){$("#txtPassword").blur(function(){$("#password\\.info").html("");var passwordTXT=$("#txtPassword").val().trim();//检查非空if(passwordTXT==""){$("#password\\.info").html("密码不能为空");return;}});});//表单提交事件$("#f").submit(function(){var ok=flag.email&&flag.password;if(!flag.email){$('login\\.info').html("用户名不能为空");return;//不做任何处理或者给个操作提示}if(!flag.password){$('login\\.info').html("密码不能为空");return;//不做任何处理或者给个操作提示}return true;} );</script></head><body><form action="../student/login.action" method="post" id="f"><table width="1189" height="460" bordercolor="#03BAa0"><tr><td height="152" colspan="3"><img src="../image/title.jpg"width="1217" height="147" /><div id="Layer2"><strong>欢迎您!</strong></div><divclass="STYLE1" id="Layer1"><div align="center"><strong><span class="STYLE3">C</span>语言考试系统</strong></div></div></td></tr><tr><td> </td><td width="398" bgcolor="#03BAa0"><div align="center" class="STYLE5"> <div align="center">学生登陆</div></div></td><form id="form1" name="form1" method="post"action="../student/login.action"><td height="79"> </td></tr><tr align="center"><td width="382" rowspan="2"> </td><td height="150" bgcolor="#03BAa0"><p align="center" class="STYLE8">用户名<input type="text" name="name" id="txtStudentname" /><a id="" style="color:red"></a></p><p align="center" class="STYLE4"><span class="STYLE8">密码<input type="text" name="password" id="txtPassword" /><a id="" style="color:red"></a></span></p></td><td width="403" height="325" rowspan="2"><div align="center"></div> <div align="center"></div></td></tr><tr align="center"><td height="23" bgcolor="#03BAa0"><div align="center"><input type="submit" bgcolor="#03BAa0" name="Submit" value="提交" /> <input type="submit" bgcolor="#03BAa0"name="Reset" value="取消" /><span id="" style="color:red"></span></div></td></tr><tr><td colspan="3" bgcolor="#03BAC9"><span class="STYLE4">太原师范计算机系</span></td></tr></table></body></html>。
JSP登陆界面
用Jsp做的一个简单的登陆界面,连接Mysql,数据库名字为school,表为user。
主要分为四个Jsp界面:index.jsp登陆界面,check.jsp检验页面,main.jsp登陆成功界面,error.jsp登陆失败界面。
如下所示:<%@page language="java"import="java.util.*" pageEncoding="utf-8"%><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>登陆界面</title></head><body><br><br><br><br><br><br><br><br><center><form action="check.jsp"method="post"><table width="380"border="2"bgcolor="#95BDFF"><tr><td><br><h1>      欢迎光临,请登陆</h1></td></tr><tr><td><br>        用户名字:  <input name="username"type="text" size="28"><br><br>        用户密码 :  <input name="userpass"type="password" size="29"><br><br>                 <input type="submit"name="submit"value="提交"style="height:30px;width:80px">           <input type="reset"name="reset"value="取消"style="height:30px;width:80px"><br> </td></tr></table></form></center></body></html><%@page language="java"import="java.sql.*" pageEncoding="utf-8"%><html><head><meta http-equiv="Content-Type" content="text/html;UTF-8"><title>登陆界面</title></head><body><%String username = new String(request.getParameter("username").getBytes("ISO-8859-1") ,"utf-8");String password = new String(request.getParameter("userpass").getBytes("ISO-8859-1") ,"utf-8");session.setAttribute("name",username);Connection dbconn = null;Statement stmt = null;ResultSet rs = null;if(username.equals("")){response.sendRedirect("index.jsp");}try{String driver = "com.mysql.jdbc.Driver";String url = "jdbc:mysql://localhost:3306/school";String user = "sa";String Password = "123";Class.forName(driver);dbconn = DriverManager.getConnection(url, user, Password);stmt = dbconn.createStatement();String sql1 = "select * from user where username='"+username+"'";rs = stmt.executeQuery(sql1);if(rs.next()){//String sql2 = "select * from user where password='"+password+"'";//rs = stmt.executeQuery(sql2);//判断用户密码是否正确String userpass = rs.getString("password");if(userpass.equals(password)){response.sendRedirect("main.jsp");}else{response.sendRedirect("error.jsp");}}else{response.sendRedirect("error.jsp");}}catch(Exception e){e.printStackTrace();}finally{rs.close();stmt.close();dbconn.close();}%></body></html><%@page language="java"import="java.util.*" import="java.text.*"pageEncoding="utf-8"%><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>登陆成功界面</title></head><body><h1>登陆成功,<%=session.getAttribute("name")%>欢迎您!</h1><%Date now = new Date();DateFormat mediumDateFormat = DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.MEDIUM);%><h2>       <%out.println(mediumDateFormat.format(now));%></h2> </body></html><%@page language="java"import="java.util.*" pageEncoding="utf-8"%><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>登陆失败界面</title></head><body><h1>登陆失败,您输入的用户名或者密码不正确!</h1></body></html>。
实用js验证用户注册登录代码
} tion insurl(obj,is){
if (document.selection && document.selection.type == "Text") {
AddTxt="[url]"+text+"[/url]";
}
this.get=function (key){
for(i=0;i<this.keys.length;i++){
if(this.keys[i]==key){
return this.values[i];
}
}
}
}
//将固定格式的Ajax传递数据拆分成 key value 的对象
e.initEvent('click',false,false);
obj.dispatchEvent(e);
}
}
//读取Cookie
function getCookie(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re)){
AddTxt="[img]"+text+"[/img]";
AddText(obj,AddTxt);
} else {
txt=prompt('请输入图片完整URL地址:','http://');
if (txt!=null) {
网页登陆代码
height:30px;
border-bottom-color:#000;
border-bottom-style:groove;
border-bottom-width:2px;
line-height:30px;
font-weight:bold;
background-color:#999;
<br/><br/>
<input type="reset" value="重置" style="width:100px height:30px; background-cloor"#666; border-style:hidden;"/>
<input type="submit" value="登录" style="width:100px height:30px; background-cloor"#666; border-style:hidden;"/>
<br/>
用户:<input type="text" style="width:200px height:30px; background-cloor"#999; border-style:hidden;"/>
<br/><br/>
密码:<input type="password" style="width:200px height:30px; background-cloor"#999; border-style:hidden;"/>
javascript弹出窗口代码大全
javascript弹出窗⼝代码⼤全如何利⽤⽹页弹出各种形式的窗⼝,我想⼤家⼤多都是知道些的,但那种多种多样的弹出式窗⼝是怎么搞出来的,今天找了⼀篇好⽂学习了: 1.弹启⼀个全屏窗⼝<html><body onload="window.open('','example01','fullscreen');">;<b></b></body></html> 2.弹启⼀个被F11化后的窗⼝<html><body onload="window.open(''','example02','channelmode');">;<b></b></body></html> 3.弹启⼀个带有收藏链接⼯具栏的窗⼝<html><body onload="window.open('','example03','width=400,height=300,directories');"><b></b></body></html> 4.⽹页对话框<html><SCRIPT LANGUAGE="javascript"><!--showModalDialog(','example04','dialogWidth:400px;dialogHeight:300px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')//--></SCRIPT><b></b></body></html><html><SCRIPT LANGUAGE="javascript"><!--showModelessDialog(','example05','dialogWidth:400px;dialogHeight:300px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes')//--></SCRIPT><b></b></body></html> showModalDialog()或是showModelessDialog() 来调⽤⽹页对话框,⾄于showModalDialog()与showModelessDialog()的区别,在于showModalDialog()打开的窗⼝(简称模式窗⼝),置在⽗窗⼝上,必须关闭才能访问⽗窗⼝(建议尽量少⽤,以免招⼈反感);showModelessDialog()dialogHeight: iHeight 设置对话框窗⼝的⾼度。
javascript常用代码大全-网页设计HTMLCSS
javasc ript常用代码大全-网页设计,HTM LCSS//打开模式对话框fun ction dose lectu ser(t xtid){ s trfea tures="dia logwi dth=500px;dialo gheig ht=360px;c enter=yes;middl e=yes ;hel p=n o;statu s=no;scrol l=no";v ar ur l,str retur n; ur l="se luser.aspx";s trret urn=w indow.show modal dialo g(url,,str featu res);}//返回模式对话框的值funct ion o kbtn_oncli ck(){v ar co mmstr=; windo w.ret urnva lue=c ommst r; wi ndow.close() ;}全屏幕打开ie 窗口var winw idth=scree n.ava ilwid th ;varwinhe ight=scree n.ava ilhei ght-20;w indow.open("mai n.asp x","s urvey windo w","t oolba r=no,width="+ w inwid th +",hei ght=" + win heigh t +",top=0,lef t=0,s croll bars=yes,r esiza ble=y es,ce nter:yes,s tatus bars=yes"); br eak //脚本中中使用xm lfu nctio n ini tiali ze(){var x mldocv ar xs ldoc xmld oc =new a ctive xobje ct(mi croso ft.xm ldom)x mldoc.asyn c = f alse;xsl doc = newactiv exobj ect(m icros oft.x mldom)xsldo c.asy nc =false;xml doc.l oad("tree.xml")x sldoc.load("tre e.xsl")fol dertr ee.in nerht ml =xmldo c.doc ument eleme nt.tr ansfo rmnod e(xsl doc)}一、验证类1、数字验证内1.1 整数1.2 大于0的整数(用于传来的id的验证) 1.3负整数的验证 1.4整数不能大于imax1.5 整数不能小于i min 2、时间类2.1 短时间,形如(13:04:06)2.2 短日期,形如(2003-12-05) 2.3长时间,形如 (2003-12-05 13:04:06) 2.4只有年和月。
javascript登陆失败打开新窗口登录代码
今天遇到个问题,后面在框架中,当判断登录失效后要返回登录页面,但登录页面却在框架内打开,我想让它直接跳出框架打开(这里不是打开新窗口),终于在网上找到了办法,分享给大家:
echo "<script language=\"javascript\">alert(‘登录已失效或没有登录,请登录!‘);location.href=‘login.php‘;</script>";
原内容是上边这样的,要想让它跳出框架打开登录页,需要使用下面的方法:
echo "<script language=\"javascript\">alert(‘登录已失效或没有登录,请登录!‘);window.top.location.href=‘login.php‘;</script>";
其实就是在跳转链接前加一个window.top。
如果在打开新窗口,可以使用js的window.open("url","打开方式"); 来打开新窗口。
登录页面HTML+CSS+JS代码
网页效果截图:源码:HTML代码(login.html)<!DOCTYPE html><html><head lang="zh-CN"><title>表单登录页面</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"><link href="login.css" rel="stylesheet" type="text/css"/><link href="dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"/> </head><body><div class="form-box"><div class="welcom"><span>欢迎您的到来</span></div><div class="input-box"><form class="form-horizontal" role="form" action="/" method="POST" enctype="text/plain"><div class="form-group "><label for="username" class="control-label col-md-3">Username:</label><div class="col-md-9"><input type="text" class="form-control" id="username" placeholder="请输入用户名"/><label class="nameinfo"></label></div></div><div class="form-group"><label for="password" class="control-label col-md-3">Password:</label><div class="col-md-9"><input type="password" maxlength="10" class="form-control" id="password" placeholder="请输入密码"/><label class="passwordinfo"></label></div></div><div class="submit-button"><button type="button"><span>Login</span></button></div></form></div></div><script src="jquery.min.js"></script><script src="dist/js/bootstrap.min.js"></script><script type="text/javascript" src="login.js"></script><!-- noscript标签检查脚本是否被禁用--><noscript><div>脚本已被禁用了,〒_〒...</div></noscript></body></html>CSS代码(login.css)*{padding:0;margin:0;}body {/* overflow:scroll; */font-family:Georgia;color:#000;}.form-box {width:470px;height:296px;margin:100px auto;border:3px #ADFF2F solid;background-color:#C5FF6D;border-radius:8px;}.welcom {width:100%;height:52px;line-height:52px;text-align:center;font-size:30px;font-family:Microsoft YaHei;font-weight:bold;border-bottom:1px #ADFF2F solid; }.input-box {position:relative;width:100%;height:248px;padding-top:30px;}.form-group {width:100%;height:50px;line-height:50px;}.form-group label,.form-group input { display:block;height:40px;font-size:16px;}.submit-button button {position:absolute;top:190px;left:2%;width:96%;height:42px;line-height:42px;border-style:none;border:2px #75FF58 solid;border-radius:3px;background-color:#86FF6D;}.submit-button span {font-size:20px;font-weight:bold;}JS代码:(login.js)$(function(){//设定两个标志,判断是否满足提交的条件var ok1=false;var ok2=false;//设定键盘事件,回车换行$(".form-control").keydown(function(event){//判断是否是回车键if(event.which == '13'){if($(this).val().length == 0){}else{var currIndex = $(this).index(':input');$(':input:eq('+(currIndex+1)+')').focus();}}});// 验证用户名$('input[id="username"]').blur(function(){var nameform=$(this).val();// 验证是否输入用户名if($(this).val() == ""){$(".nameinfo").html("用户名不能为空!");$(".nameinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}// 验证用户名是否大于六位else if($(this).val().length < 6){$(".nameinfo").html("用户名至少为6位!");$(".nameinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}//验证用户名格式是否正确elseif(!nameform.match(/^[a-zA-Z][a-zA-Z0-9@]*$/)){$(".nameinfo").html("用户名格式不正确!");$(".nameinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}else{$(".nameinfo").html("输入正确");$(".nameinfo").css({"color":"green","font-family":"KaiTi","font-size":"16px"});//验证通过,将标志位置为trueok1 = true;}});//验证密码$('input[id="password"]').blur(function(){if($(this).val() == "" ){$(".passwordinfo").html("密码不能为空!");$(".passwordinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}else if($(this).val().length < 6){$(".passwordinfo").html("密码至少为6位!");$(".passwordinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}else{$(".passwordinfo").html("输入正确");$(".passwordinfo").css({"color":"green","font-family":"KaiTi","font-size":"16px"});ok2 = true;}});//输入不合法的情况下,获取焦点时清空错误输入$('input[id="username"]').focus(function(){if(!ok1){$('input[id="username"]').val("");}});$('input[id="password"]').focus(function(){if(!ok2){$('input[id="password"]').val("");}});//点击进行用户名后台验证,通过验证后实现页面跳转$(".submit-button button").click(function(){username=$("#username").val();password=$("#password").val();if(ok1 && ok2){//普通方式$.ajax({url:"/Login/ValidUser",type:"POST",dataType:"json",data:{username:"+username+",password:"+password+"},success:function(){window.location.href="menu.html";},error:function(){window.location.href="menu.html";}});//deferred模式// $.ajax("/Login/ValidUser",// {type:"post"},// {dataType:"json"},// {data:{username:"+username+",password:"+password+"}} // ).done(function(){window.location.href="menu.html";})// .fail(function(){window.location.href="menu.html";})}return false;//抑制了浏览器的默认点击行为});});。
登陆界面代码
登陆界⾯代码1、设计思想添加窗⼝界⾯,想i⾯添加⼀系列组件。
输⼊账号密码和验证码后,如果验证码正确,进⾏注册,否则注册失败。
注册成功后,验证码⾃动刷新,并将注册的帐号和密码保存。
注册失败后,验证码刷新,从新注册。
⽽后进⾏登录,输⼊帐号密码和验证码,当三个都输⼊对的时候,登录成功,否则登录失败,刷新验证码重新登录。
当点击刷新验证码后,验证码⾃动刷新。
2、流程图3、源程序代码package java作业;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Random;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;class chuang extends JFrame implements ActionListener{private JTextField txt1;private JTextField txt2;private String base = "abcdefghijklmnopqrstuvwxyz0123456789";private String zifu;private JLabel haha;private JTextField txt3;private JButton d;private JButton dl;private JButton zc;private String zhanghao;private String mima;private String yanzheng;private StringBuffer sb;chuang(){setBounds(800,400,300,250);setVisible(true);setTitle("界⾯");setDefaultCloseOperation(EXIT_ON_CLOSE);setLayout(null);JLabel zh=new JLabel("帐号:");zh.setBounds(20,15,50,25);add(zh);JLabel mm=new JLabel("密码:");mm.setBounds(20,50,50,25);add(mm);JLabel en=new JLabel("点击按钮后,放⼤窗⼝刷新验证码");en.setBounds(20,150,200,25);add(en);Random random = new Random();sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length());sb.append(base.charAt(number));}haha=new JLabel(sb.toString()+":");haha.setBounds(20,85,50,25);add(haha);txt1 = new JTextField(20);txt1.setBounds(65,15,150,25);add(txt1);txt1.setText("请输⼊帐号");txt2 = new JTextField(20);txt2.setBounds(65,50,150,25);add(txt2);txt2.setText("请输⼊密码");txt3 = new JTextField(20);txt3.setBounds(65,85,100,25);add(txt3);txt3.setText("请输⼊验证码");d=new JButton("刷新验证码");d.addActionListener(this);d.setBounds(170,85,100,24);add(d);dl=new JButton("登录");dl.addActionListener(this);dl.setBounds(35,120,75,24);add(dl);zc=new JButton("注册");zc.addActionListener(this);zc.setBounds(120,120,75,24);add(zc);validate();}public void actionPerformed(ActionEvent e){if(e.getSource()==d){remove(haha);Random random = new Random();sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length());sb.append(base.charAt(number));}haha=new JLabel(sb.toString()+":");haha.setBounds(20,85,50,25);add(haha);validate();}else if(e.getSource()==dl){yanzheng=txt3.getText();if(yanzheng.equals(sb.toString())&&txt1.getText().equals(zhanghao)&&txt2.getText().equals(mima)) {JFrame ha=new JFrame("登录界⾯");ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("登录成功!");ha.add(hao);validate();}else{JFrame ha=new JFrame("登录界⾯"); ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("登录失败!"); ha.add(hao);validate();}}else if(e.getSource()==zc){yanzheng=txt3.getText();zhanghao=txt1.getText();mima=txt2.getText();if(yanzheng.equals(sb.toString())){JFrame ha=new JFrame("注册界⾯"); ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("注册成功!"); ha.add(hao);validate();}else{JFrame ha=new JFrame("注册界⾯"); ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("注册失败!"); ha.add(hao);validate();}remove(haha);Random random = new Random();sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length()); sb.append(base.charAt(number));}haha=new JLabel(sb.toString()+":"); haha.setBounds(20,85,50,25);add(haha);validate();}}public void shuzi(){Random random = new Random(); StringBuffer sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length()); sb.append(base.charAt(number));}System.out.println(sb.toString());}}public class suiji {public static void main(String args[]){new chuang();}}4、结果截图。
jsp注册登录页面代码
jsp注册页面代码用户信息的bean:package chen;public class UserBean{private String userid;private String password;public void setUserId(String userid){erid=userid;}public void setPassword(String password){this.password=password;}public String getUserId(){return erid;}public String getPassword(){return this.password;}}提交数据库的bean:package chen;import com.mysql.jdbc.Driver;import java.sql.*;public class UserRegister{private UserBean userBean;private Connection con;//获得数据库连接。
public UserRegister(){String url="jdbc:mysql://localhost/"+"chao"+"?user="+"root"+"&password="+"850629"; try{Class.forName("com.mysql.jdbc.Driver").newInstance();con = DriverManager.getConnection(url);}catch(Exception e){e.printStackTrace();}}//设置待注册的用户信息。
public void setUserBean(UserBean userBean){erBean=userBean;}//进行注册public void regist() throws Exception{String reg="insert into userinfo(userid,password) values(?,?)";try{PreparedStatement pstmt=con.prepareStatement(reg);pstmt.setString(1,userBean.getUserId());pstmt.setString(2,userBean.getPassword());pstmt.executeUpdate();}catch(Exception e){e.printStackTrace();throw e;}}}提交注册数据进入数据库:<%@ page contentType="text/html;charset=gb2312" pageEncoding="gb2312" import="chen.*" %><jsp:useBean id="userBean" class="erBean" scope="request"><jsp:setProperty name="userBean" property="*"/></jsp:useBean><jsp:useBean id="regist" class="erRegister" scope="request"/><html><head><title> 用户信息注册页面</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body>String userid =request.getParameter("userid");String password = request.getParameter("password");userBean.setUserId(userid);userBean.setPassword(password);System.out.println(userid+password);%><% try{regist.setUserBean(userBean);out.println(userid);regist.regist();out.println("注册成功");}catch(Exception e){out.println(e.getMessage());}%><br><a href="login.jsp">返回</a></body></html>登陆验证页面:<%@page import="java.sql.*" contentType="text/html;charset=GB2312" %><%@page import="java.util.*"%><%String userid1=new String(request.getParameter("userid"));String password1=new String(request.getParameter("password"));Class.forName("com.mysql.jdbc.Driver");Connectioncon=DriverManager.getConnection("jdbc:mysql://localhost:3306/chao","root","850629"); Statement stmt=con.createStatement();String sql="select * from userinfo where userid='"+userid1+"';";ResultSet rs=stmt.executeQuery(sql);if(rs.next()){String password=new String(rs.getString("password"));if(password.equals(password1)){session.setAttribute("userid1",userid1);response.sendRedirect("sucess.jsp");}else{response.sendRedirect("login.jsp");}}else{response.sendRedirect("login.jsp");%>登陆页面:<%@ page contentType="text/html; charset=gb2312" %><html><body><form method="get" action="checklogin.jsp"><table><tr><td> 输入用户名:</td><td><input type=text name=userid ></td></tr><tr><td>输入密码:</td><td><input type=password name=password></td></tr><tr><td><input type=submit value=确认></td></tr></table></form><form action="register.jsp"><input type=submit value=注册></form></body></html>注册页面:<%@page contentType="text/html; charset=gb2312" language="java" import="java.util.*,java.io.*"%><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><center><h1>注册新用户</h1><form action="adduser.jsp" method=post><table border="1" bgcolor="#0099CC"><tr><td> 用户名:<input type="text" name="userid"></td></tr><tr valign="middle"><td> 密码:<input type="password" name="password" readonly></td></tr><tr><td><input type=submit value=提交></td></tr></table></form></center></body></html>登陆成功页面:<%@page import="java.util.*" contentType="text/html; charset=gb2312" %> <%@include file="trans.jsp"%><html><head><title>sucess</title></head><body bgcolor="#ffffff"><h1>登录成功,欢迎您!</h1><%=trans(session.getAttribute("userid1"))%></body></html>登录前台界面设计代码如下:<%@ page contentType="text/html; charset=gb2312"language="java" import="java.sql.*" errorPage="" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01Transitional//EN"><html><head><title>Register Test!</title></head><body> 登录界面!! <br><form method="post" action="cheklogin.jsp" name="form"> <table width="183" height="85" border="1"><tr><td>User:</td><td><input type="text" name="user" size="13"> </td></tr><tr><td>Password:</td><td><input type="Password" name="password" size="13" > </td></tr><tr><td><input type="Submit" name="bt1" text="OK" value="登录"></td><td><a href="do_register.jsp" target="_parent">新用户注册<br></a></td></tr></table></form></body></html>后台处理程序添加一个Jsp 右键webRoot : New—>JSP 名称cheklogin .jsp代码如下:<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %><%String path = request.getContextPath();String basePath =request.getScheme()+"://"+request.getServerName()+":"+req uest.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01Transitional//EN"><html><head><base href="<%=basePath%>"><title>My JSP 'cheklogin.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"><meta http-equiv="keywords"content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"> <!--<link rel="stylesheet" type="text/css"href="styles.css">--></head><body><%String usr = request.getParameter("user");String pwd = request.getParameter("password");//String usr = "hurui";//String pwd = "free889";Connection con = null;Statement sm = null;ResultSet rs = null;try{Class.forName("rmix.jdbc.IfxDriver").newInstan ce(); //装载jdbc 驱动String url ="jdbc:informix-sqli://192.168.5.249:9003/testuser:informi xserver=iservice_online_net"; // 定义数据库连接URLcon =DriverManager.getConnection(url,"informix","informix"); //获取数据连接实例sm = con.createStatement(); //获取Statement 的实例rs = sm.executeQuery("select * from new_test_user where login='"+usr+"' and password='"+pwd+"'"); //执行查询语句,并返回给结果集}catch(Exception e){e.printStackTrace( );}//添加表格%><table border="1" width="80%"><tr><td>你的用户名是:</td><td>你的密码是:</td></tr><%while (rs.next()) { //循环输出产品信息String var_name=rs.getString(1);String var_val=rs.getString(2);%><tr><%if(usr == var_name || pwd ==var_val){System.out.println("success!");}%><td><%= var_name %></td><td><%= var_val %></td></tr><%}rs.close();sm.close();con.close();%></body></html>验证试验是否成功:输入:用户名:admin密码:11111。
js页面跳转参考代码大全
js页⾯跳转参考代码⼤全整理⼀下JS页⾯跳转参考代码第⼀种:<script language=/"javascript/" type=/"text/javascript/">window.location.href=/"login.jsp?backurl=/"+window.location.href;</script>第⼆种:<script language=/"javascript/">alert(/"返回/");window.history.back(-1);</script>第三种:<script language=/"javascript/">window.navigate(/"top.jsp/");</script>第四种:<script language=/"JavaScript/">self.location=’top.htm’;</script>第五种:<script language=/"javascript/">alert(/"⾮法访问!/");top.location=’xx.jsp’;</script>=====javascript中弹出选择框跳转到其他页⾯=====<script language=/"javascript/"><!--function logout()...{if (confirm(/"你确定要注销⾝份吗?是-选择确定,否-选择取消/"))...{window.location.href=/"logout.asp?act=logout/"}}--></script>=====javascript中弹出提⽰框跳转到其他页⾯=====<script language=/"javascript/"><!--function logout()...{alert(/"你确定要注销⾝份吗?/");window.location.href=/"logout.asp?act=logout/"}--></script>。
网页登录代码
<input type="submit" name="Submit" value="重置" />
</label>
</p>
</form> </td>
</tr>
<p>密码:
<label>
<input type="text" name="textfield2" />
</label>
</p>
பைடு நூலகம் <p>
</tr>
</table>
</td>
<td width="83"> </td>
</tr>
<tr>
<td height="3243"> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<script language="javascript">
function checkempty(){
if(document.form.account.value==""){
登录界面代码
<br />
<asp:Label ID="lbHint" runat="server" ForeColor="#FF3300"></asp:Label>
<br />
<br />
<span class="style2">登录信息:</span><asp:Panel ID="Panel1" runat="server"
BackColor="#FFFF99" BorderColor="#FFCC99" BorderStyle="Solid" Height="27px"
请从上面的菜单选择你的操作!<br />
<br />
<asp:Panel ID="Panel1" runat="server" Height="137px" Width="338px"
BackColor="#FFFF99">
<head id="Head1" runat="server">
<title>查看用户信息</title>
<style type="text/css">
.style1
web JSP 简单的登录+注册页面代码
简单做了界面,代码功能应该没有问题,简单做个文档分享一下。
登录界面denglu.jsp:<%@page contentType="text/html;charset=gb2312" %><html><head><title>登录界面</title><script>function check(){if(erN.value==""){alert("用户名不能为空");erN.focus();return false;}if(erP.value==""){alert("密码不能为空");erP.focus();return false;}document.dlForm.submit();return true;}</script></head><body><center><font size="6"> 欢迎进入登录界面</font><form action="dlhou.jsp" onsubmit="return check()" method="post" name="dlForm"><p>用户名:<input type="text" name="UserN" style="width: 148px; "/></p><p>密 码:<input type="password" name="UserP" style="width: 146px; "/></p><p><input type="submit" value=" 登 录 " style="height: 43px; "/> <input type="button" value="忘记密码" onclick="parent.location.href('wangji.jsp')" style="height: 43px; "/> <input type="button" value="返回主页" onclick="parent.location.href('welcome.jsp')" style="height: 43px; "/></p></FORM> </center></body></html>dlhou.jsp<%@page contentType="text/html;charset=gb2312" %><%@page language="java" import="java.sql.*" %><jsp:useBean id="SQLbean" scope="session" class="lian.Lian"/><html><head><title>登录状态</title></head><body><div align="center"><span class="style1">登录状态</span><br><hr><br></div><%String userN=request.getParameter("UserN");String userP=request.getParameter("UserP");// out.print(userN);String sql="select * from yxx where yname='"+userN+"'";SQLbean.OpenConn();ResultSet rs=SQLbean.executeQuery(sql);if(!rs.next()){%><script>alert("用户名不存在!");window.location.href="denglu.jsp";</script><%}// while(rs.next()){String p=rs.getString("ypassword").trim();if(p.equals(userP.trim()))// response.sendRedirect("zhu.jsp?param="+userN);{session.setAttribute("yhm",userN);// response.sendRedirect("zhu.jsp");%><script>alert("恭喜您,登录成功!");window.location.href="zhu.jsp";</script><%}else{%><script>alert("密码错误!");window.location.href="denglu.jsp";</script><%}}rs.close();SQLbean.closeSt();SQLbean.closeConn();%></body></html><%@page contentType="text/html;charset=gb2312" %><html><head><title>注册界面</title><script>function zcheck(){if(erN.value==""){alert("用户名不能为空");erN.focus();return false;}if(erP.value==""){alert("密码不能为空");erP.focus();return false;}if(document.zcForm.reUserP.value==""){alert("确认密码不能为空");document.zcForm.reUserP.focus();return false;}if(document.zcForm.reUserP.value!=erP.value){alert("确认密码和密码不符");document.zcForm.reUserP.focus();return false;}return true;}</script></head><body><center><font size="6"> 欢迎进入注册界面</font><br><br><font size="4"> 基本信息注册</font><form action="zchou.jsp" onsubmit="return zcheck()" method="post" name="zcForm"><p> 用户名: <input type="text" name="UserN" style="width: 155px; "/> <font color="red">*</font></p><p> 密 码:<input type="password" name="UserP" style="width: 155px; "/> <font color="red">*</font></p> <p> 确认密码:<input type="password" name="reUserP" style="width: 155px; "/> <font color="red">*</font></p><p> 性 别: <input type="radio" name="UserS" value="Mr." checked="checked"/>男 <input type="radio" name="UserS" value="Ms."/>女 <font color="red">*</font></p><p>年 龄:<input type="text" name="UserA" style="width: 155px; "/></p><br><font size="4"> 密码找回问题设置</font><p>问题1:你最尊敬的老师是?答案1:<input type="text" name="Q1" style="width: 155px; "/> <font color="red">*</font></p><p>问题2:你最喜欢的学科是?答案2:<input type="text" name="Q2" style="width: 155px; "/> <font color="red">*</font></p><p>问题3:你最喜欢的运动是?答案3:<input type="text" name="Q3" style="width: 155px; "/> <font color="red">*</font></p><p><input type="submit" name="确定" value=" 确 定 " style="height: 33px; "> <input type="button" value="返回主页" onclick="parent.location.href('welcome.jsp')" style="height: 33px; "/></p></form></center></body></html><%@page contentType="text/html;charset=gb2312" %><%@page language="java" import="java.sql.*" %><jsp:useBean id="SQLbean" scope="session" class="lian.Lian"/><html><head><title>注册状态</title></head><body><%String userN=request.getParameter("UserN");String userP=request.getParameter("UserP");String userS=request.getParameter("UserS");String userA=request.getParameter("UserA");String q1=request.getParameter("Q1");String q2=request.getParameter("Q2");String q3=request.getParameter("Q3");SQLbean.OpenConn();String sqly="select * from yxx where yname='"+userN+"'";ResultSet rsy=SQLbean.executeQuery(sqly);if(rsy.next()){%><script>alert("用户名已被注册,请更换用户名");window.location.href="zhuce.jsp";</script><%}else{String sql="insert into yxx values('"+userN+"','"+userP+"','"+userS+"','"+userA+"')";String sql2="insert into yyz values('"+userN+"','"+q1+"','"+q2+"','"+q3+"')";SQLbean.executeUpdate(sql);SQLbean.executeUpdate(sql2);SQLbean.closeSt();SQLbean.closeConn();%><script>alert("注册成功,将跳转登录界面");window.location.href="denglu.jsp";//wrq经试验表明sendRedirect()还没显示alert 提示就已经跳转</script><%}%></body></html>。
JavaScript把网站设为首页代码大全
JavaScript把网站设为首页代码大全。
1.鼠标指向时提示设为首页,将下列代码插入<body>区中:<a href= onmouseover="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.173it. cn');" target="_blank">设为首页</a>2.设为首页代码,加入收藏夹,把以下代码加入<Body>相应位置:<a target=_top href="javascript:window.external.addFavorite('','网页教学网');">加入收藏</a><a href='#' onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('http:/');">设为首页</a>3.打开页面时自动弹出窗口询问是否设为首页,将以下代码放在<head></head>之间:<script language="javascript">function myhomepage(){this.homepage.style.behavior='url(#default#homepage)';this.homepage.sethomepage('http://www. ');}</script><p align="center"><a href=http:/ name="homepage"onclick="myhomepage();"></a>再将下面代码加入<body>内:onload="myhomepage();"即:<body onload="myhomepage();">4.离开时自动提示设为首页,替换<body>标签为:<body onunload="BASEBody.style.behavior='url(#default#homepage)';if(!(BASEBody.isHomePage('htt p://')))BASEBody.setHomePage('http://');">更多信息请查看IT技术专栏。
javascript中的login命令参数
javascript中的login命令参数在JavaScript中,没有内置的login命令。
然而,您可能是在特定的框架或库中使用login命令,例如在Node.js的Express框架中。
在Express框架中,您可以使用中间件来处理登录验证。
一个常见的中间件是passport.js,它提供了各种策略来处理身份验证。
使用passport.js时,您可以定义一个登录策略,并将用户对象存储在会话中或将其存储在数据库中。
以下是一个使用passport.js处理登录的示例:javascriptconst express = require('express');const passport = require('passport');const LocalStrategy = require('passport-local').Strategy;const app = express();e(passport.initialize());e(passport.session());e(new LocalStrategy(function(username, password, done) {// 在这里进行用户验证逻辑,检查数据库或其他数据源以确认用户凭据是否有效// 如果验证成功,返回成功的回调函数,否则返回失败的回调函数}));app.post('/login', passport.authenticate('local',{ failureRedirect: '/login-failed' }), function(req, res) { // 登录成功后,将用户对象存储在会话中,然后重定向到登录成功页面或执行其他操作});在上述示例中,passport.authenticate('local')中间件用于处理本地身份验证策略。
Vue实现单点登录控件的完整代码
Vue实现单点登录控件的完整代码Vue.js是一种用于构建用户界面的渐进式JavaScript框架。
要实现单点登录(Single Sign-On)控件,需要使用Vue.js的前端开发技术和后端接口对接的知识。
以下是一个基于Vue.js的单点登录控件的完整代码示例。
前端代码:```vue<template><div><h1>单点登录</h1><div v-if="!loggedIn"></div><div v-else><p>欢迎,{{ username }}!</p></div></div></template><script>export defaultreturnloggedIn: false,username: ''};},methods:logi//发起登录请求,获取登录凭证//使用凭证向后端验证登录信息// 登录成功后设置loggedIn为true,并保存用户名this.loggedIn = true;ername = 'John Doe';},logou//发起注销请求,使凭证无效// 注销成功后设置loggedIn为false,并清除用户名this.loggedIn = false;ername = '';}};</script>```在上面的代码示例中,模板中根据loggedIn的值来决定显示登录还是欢迎页面。
当loggedIn为false时,显示登录按钮。
点击登录按钮时,调用login方法模拟登录请求,并设置loggedIn为true,保存用户名。
当loggedIn为true时,显示欢迎页面,并展示用户名。
点击注销按钮时,调用logout方法模拟注销请求,并设置loggedIn为false,清除用户名。
javascript弹出和关闭网页窗口代码大全
javascript弹出和关闭网页窗口代码大全javascript弹出和关闭网页窗口代码大全//关闭,父窗口和子窗口都不弹出对话框,直接关闭this.Response.Write("<script> ");this.Response.Write("{top.opener =null;top.close();}");this.Response.Write("</script> ");//关闭,父窗口弹出对话框,子窗口直接关闭this.Response.Write("<script language=javascript> window.close();</script> ");//弹出窗口刷新当前页面width=200 height=200菜单。
菜单栏,工具条,地址栏,状态栏全没有this.Response.Write("<script language=javascript> window.open('rows.aspx','newwindow','width=200,height=200') </script> ");//弹出窗口刷新当前页面this.Response.Write("<script language=javascript> window.open('rows.aspx')</script> ");this.Response.Write("<script>window.open('WebForm2.aspx','_blank');</script> ");//弹出提示窗口跳到webform2.aspx页(在一个IE窗口中)this.Response.Write(" <script language=javascript> alert('注册成功');window.window.location.href='WebForm2.aspx';</script> ");//关闭当前子窗口,刷新父窗口this.Response.Write("<script>window.opener.location.href=window.opener.location.href;wind ow.close();</script> ");this.Response.Write("<script>window.opener.location.replace(window.opener.document.referr er);window.close();</script> ");//子窗口刷新父窗口this.Response.Write("<script>window.opener.location.href=window.opener.location.href;</scri pt> ");this.Response.Write("<script>window.opener.location.href='WebForm1.aspx';</script> ");//弹出提示窗口.确定后弹出子窗口(WebForm2.aspx)this.Response.Write("<script language='javascript'> alert('发表成功!');window.open('WebForm2.aspx')</script> ");//弹出提示窗口,确定后,刷新父窗口this.Response.Write("<script> alert('发表成功!');window.opener.location.href=window.opener.location.href;</s cript> ");//弹出相同的一页<INPUT type="button" value="Button" onclick="javascript:window.open(window.location.href)">//Response.Write("parent.mainFrameBottom.location.href='y ourwebform.aspx?temp=" +str+"';");<SCRIPT LANGUAGE="javascript"><!--window.open ('page.html', 'newwindow', 'height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no') //这句要写成一行--></SCRIPT>参数解释:<SCRIPT LANGUAGE="javascript"> js脚本开始;window.open 弹出新窗口的命令;'page.html' 弹出窗口的文件名;'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;height=100 窗口高度;width=400 窗口宽度;top=0 窗口距离屏幕上方的象素值;left=0 窗口距离屏幕左侧的象素值;toolbar=no 是否显示工具栏,yes为显示;menubar,scrollbars 表示菜单栏和滚动栏。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>注册</title><style type="text/css">input[type = "text"], input[type = "password"] {width: 150px;}table{background-color:pink}</style></head><body><div><div class="login_step"><div align="center">注册步骤:<span class="red_bold">1.填写信息</span> > 2.提交</div></div><center><form name="myform" action="success.html" method="post" onsubmit="return check()" ><table width="45%" height="50%" border="1" cellspacing="0" ><tr><th colspan="2">注册个人信息(*为必填的空!)</th></tr><tr><td height="36" align="right">用户名:</td><td><input type="text" name="username" id="username" onBlur="check()" /><span id="usernames"></span> * </td></tr><tr><td height="38" align="right">设置密码:</td><td><input type="password" name="psw" id="psw" onBlur="check()"/><span id="psws"></span> * </td></tr><tr><td align="right" >密码确认:</td><td><input type="password" name="psw-enter" id="psw-enter" onBlur="passwords()"/><span id="psws-enter"></span> *</td></tr><tr><td height="41" align="right">性别:</td><td><input type="radio" name="sex" value="man" checked />男 <input type="radio" name="sex" value="women"/>女</td></tr><tr><td height="45" align="right">出生日期:</td><td><select name="year" id="year"><option value="">请选择</option><option value="1990" selected>1990</option><option value="1991" >1991</option><option value="1992">1992</option><option value="1993">1993</option><option value="1994">1994</option><option value="1995">1995</option><option value="1996">1996</option><option value="1997">1997</option><option value="1998">1998</option><option value="1999">1999</option><option value="2000">2000</option></select>年<select name="month" id="month"><option value="">请选择</option><option value="1" selected>1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option></select>月<select name="day" id="day"><option value="">请选择</option><option value="1" selected>1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option></select>日</font></td></tr><tr><td height="32" align="right">身份证号码:</td> <td><input type="text" value="" id="sfz" onBlur="check()" /><span id="shen"></span>* </td></tr><tr><td height="44" align="right">联系电话:</td> <td><input type="text" value="" id="phone" onBlur="check()" /><span id="phones"></span>* </td></tr><tr><td height="39" align="right">Emai:</td><td><input type="text" id="email" value="" onBlur="check()"/><span id="emails"></span>*</td><tr><td align="right">个人说明:</td><td><font color="#6600CC"><textarea id="jian"></textarea></font></td></tr><tr><td colspan="2" align="center"><input type="submit" value="提交" /> <input type="reset" value="重置" /></font></td></tr></table></form></center><script type="text/javaScript">function username(){var username = document.getElementById("username").value; //用户名//用户名的判断var r = /^[A-Za-z]+$/;if(username == ""){document.getElementById("usernames").innerHTML = "<font color='red'>用户名不可以为空</font>";return false;}else if(username !=""){if(username.length<3){document.getElementById("usernames").innerHTML = "<font color='red'>用户名至少3位</font>";return false;}else{document.getElementById("usernames").innerHTML = "<font color='green'>恭喜你,您的用户名可以使用</font>";return true;}}}function password(){var psw = document.getElementById("psw").value;//密码//密码的判断if(psw==""){document.getElementById("psws").innerHTML = "<font color='red'>密码不可以为空</font>";return false;}else if(psw !=""){if(psw.length<6){document.getElementById("psws").innerHTML = "<font color='red'>密码至少六位</font>";return false;}else{document.getElementById("psws").innerHTML = "<font color='green'>密码设置成功!</font>";return true;}}}function passwords(){var psw = document.getElementById("psw").value;var p=document.getElementById("psw-enter").value;if(p!=psw){document.getElementById("psws-enter").innerHTML = "<font color='red'>密码与确认密码不同</font>";}else{document.getElementById("psws-enter").innerHTML = "<font color='green'>确认密码输入正确</font>";}}function sex(){var sex = document.getElementsByName("sex");var sex1 = "";for(var i=0;i<sex.length;i++){if(sex[i].checked==true){sex1 = sex[i].value;}}}function shijizn(){var year = document.getElementById("year").value; //出生年份var month= document.getElementById("month").value; //出生月份var day = document.getElementById("day").value; //出生的日期}//身份证的验证function sfz(){var sfz = document.getElementById("sfz").value;//身份证号码var shenfenz=/\d{15}|\d{18}/;if(sfz==""){document.getElementById("shen").innerHTML = "<font color='red'>身份证不能为空</font>";return false;}if(sfz !=""){if(!(shenfenz.test(sfz))){document.getElementById("shen").innerHTML = "<font color='red'>身份证格式不正确</font>";return false;}else{document.getElementById("shen").innerHTML = "<font color='green'>身份证正确</font>";return true;}}}function phone(){var phone = document.getElementById("phone").value; //联系电话//正则表达式使用方法var reg= /^\d{11}$/; //if(phone==""){document.getElementById("phones").innerHTML = "<font color='red'>联系电话格不能为空</font>";return false;}if(phone !=""){if(!(reg.test(phone))){document.getElementById("phones").innerHTML = "<font color='red'>联系电话格式不正确</font>";return false;}else {document.getElementById("phones").innerHTML = "<font color='green'>联系电话输入正确</font>";return true;}}}function email(){var email = document.getElementById("email").value; //email邮箱//alert(email);//邮箱验证var e=/^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/;if(email==""){document.getElementById("emails").innerHTML = "<font color='red'>邮箱不能为空</font>";return false;}if(email !=""){if(!(e.test(email))){document.getElementById("emails").innerHTML = "<font color='red'>邮箱格式不正确</font>";return false;}else{document.getElementById("emails").innerHTML = "<font color='green'>邮箱正确</font>";return true;}}}function check(){if (username()&&password()&&sfz()&&phone()&&email()) {return true;}else {return false;}}</script></body></html>。