㈠ JS表单验证代码

我就简单的写个 希望可以帮助您

==================================

<!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=gb2312" />
<title>测试页面</title>
<script type="text/javascript">
function checkform(){
//验证用户名
if($("username").value == ""){
$("n_msg").innerHTML ="用户名不可以为空";
$("username").select();
$("username").focus();
return false;
}else{
if($("username").value.length < 6){
$("n_msg").innerHTML = "用户名必须大于6个字符";
$("username").select();
$("username").focus();
return false;
}
}
//验证密码
if($("password").value == ""){
$("p_msg").innerHTML ="密码不可以为空";
$("password").select();
$("password").focus();
return false;
}else{
if($("password").value.length < 10){
$("p_msg").innerHTML = "密码必须大于10个字符";
$("password").select();
$("password").focus();
return false;
}
}
//.....(下面的可以以此类推)
return true;
}

function $(id){
return document.getElementById(id);
}
</script>
<style type="text/css">
body{ font:12px 宋体}
.c_red{ color:#f00}
</style>
</head>

<body>
<table width="500" border="0" cellspacing="0" cellpadding="0">
<form method="post" onsubmit="return checkform()">
<tr>
<td width="89">用户名</td>
<td width="223"><input name="username" type="text" id="username" /></td>
<td width="188" id="n_msg" class="c_red"></td>
</tr>
<tr>
<td>密码</td>
<td><input name="password" type="password" id="password" /></td>
<td id="p_msg" class="c_red"></td>
</tr>
<tr>
<td colspan="3"><input name="sub" type="submit" id="sub" value="提交" /></td>
</tr>
</form>
</table>

</body>
</html>

===========================

上面的为代码部分 我已经调试没问题 希望可以帮助您
祝早日解决~

㈡ 用户登录验证的代码怎么写

<br>
<%
//接受参数,request.getParameter("参数名称"),此方法返回String类型
String name = request.getParameter("username");
String password = request.getParameter("userpassword");
%>
<%
if(name.equals("handson")&&password.equals("handson")){
//合法用户
%>
<%@include file = "login_success.jsp" %>
<%
} else{
%>
<%@include file = "login_failure.jsp" %>
<%
}
%>
</center>

㈢ 验证码 代码如何编写

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<%@ page contentType="text/html;charset=GB2312" %>
<html> <head><title>登录页面</title> <script type="text/javascript"> function reloadcode(){ var verify=document.getElementById('code'); verify.setAttribute('src','makeCertPic.jsp?it='+Math.random()); } </script></head> <body> <table align="center" border="0"> <tr align="center"> <td> <font color="red"> <html:errors/> </font> </td> </tr> <tr align="center"> <td>系统登录</td> </tr> <form action="loginCheck.jsp" method="post" focus="username"> <tr><td>用户名:<input type="text" name="username"/></td></tr> <tr><td>密 码:<input type="password"name="password"/></td></tr> <tr> <td>验证码:<input type="text" name="username"/><img src="makeCertPic.jsp" id="code" onclick="reloadcode()" style="cursor: pointer;" alt="看不清楚,换一张"> </td> </tr> <tr align="left"> <td> <input type="submit" value="确定"/> </td> </tr> </form> </table> </body></html>

㈣ STEAM验证代码

异地登录steam会给你发邮件来接受验证码。

点击小箭头——邮件有乱码就可以正常回查看了答。(如图所示)

㈤ 怎样验证电子邮件在哪里看验证代码

例:如下图,可以看到填写的验证电子邮件为126的电子邮箱。具体步骤如下:

1、打开保留的电子邮件网站,在电子邮件网站中输入账号和密码,然后单击“登录”。例如126电子邮件网站。

㈥ 代码和校验

这是数据通信中的一个问题.也是对数据通信纠错的一种方式.这样说吧,假定对方的网卡给你发送类似10100101这样的一些封包,由于网线可能会受到磁场等干扰元素的干扰,你怎么确信你接收到的包是正确的?

显然这样要有一个校验与纠错的机制,比如对于校验,将前边所以有数字进行位求和,就是将每个bit进行相加,得到的最终结果以二进制补到包的最后,当然这里加出来的结果是4(100),也就是最终形成10100101100发送给你,如果由于信号的突变或时某种原因,将你接到的结果前8位(数据包)也按同样的方法计算校校验码,然后与8位后的结果进行比较,如果不相等,则一定是出错了!这就是校验,但我所说的是位比较的方式,显然只能校验错误,不能校验正确.也就是说相等也未必是正确的信息.但你知道了,我是以bit进行校验的,而你的文中是要求是字节进行校验的,其实没有什么区别.只不过现在网络中的小封包一般会被丢掉,而封包内不可能只有一个字节的.

而你文其实就是一个校验算法.有些较好的算法还可能使用有纠错码,不但能发现错误,还能改正错误.当然也是有限制的.比如只能改正一个bit或几个bit,如果超出,则要求重新发包.

㈦ 验证码 代码

你在java发这个问题!我就把java 的验证码源码给你。

<tr>
<td><font color="#FFFFFF">验证码:</font></td>
<td width="22%"><input type="text" name="randomcode" class='input' size='4' maxlength="8" style="width:50px;height:18px" onKeyDown="if (event.keyCode==13)submitLogin();">
</td>
<td width="48%"><img src="./showradomcode.jsp"></td>
</tr>

文件二:showradomcode.jsp
<%@ page contentType="image/jpeg" import="java.awt.image.*,javax.imageio.*" %><jsp:useBean id="rc" class="com.hanweb.sso.ldap.util.RandomChar" scope="page"/><%
//设置页面不缓存
//response.reset();
response.setContentType("image/jpeg");
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
//在内存中创建图象宽60 高18 4个字符 0条干扰线
BufferedImage image = rc.getRandomImage(58, 18, 4, 1);
//设置其session值
session.setAttribute("jcmsrandomchar", rc.getRandomString());
session.setMaxInactiveInterval(100000000);
ImageIO.write(image, "JPEG", response.getOutputStream());
%>

文件三:RandomChar.java
package com.hanweb.sso.ldap.util;
/**
* Title: 随机码图形生成程序的处理 Description:
* 为了加强网络安全,防止黑课工具对系统的攻击,现在通用随机码来解决这个问题,因为每一次产生的随机码是随机的,所以使用穷举法破解密码的工具就无能为力了
* Copyright: Copyright (c) 2004-2010 Company: SDLDAP
*
* @author LiChanglai
* @version 1.0
*/
import java.util.*;
import java.awt.*;
import java.awt.image.*;
public class RandomChar {
/**
* 给定范围获得随机颜色
*
* @param fc
* int 参数1
* @param bc
* int 参数2
* @return Color 返回的color对象
*/
private String strRandomString; // 生成的随机数
/**
* 取其生成的随机数
*
* @return String
*/
public String getRandomString() {
return strRandomString;
}
/**
* 设置其生成的随数
*
* @param randomString
* String
*/
public void setRandomString(String randomString) {
this.strRandomString = randomString;
}
/**
* 取其某一范围的color
*
* @param fc
* int 范围参数1
* @param bc
* int 范围参数2
* @return Color
*/
private Color getRandColor(int fc, int bc) {
// 取其随机颜色
Random random = new Random();
if (fc > 255) {
fc = 255;
}
if (bc > 255) {
bc = 255;
}
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
/**
* 用于生成其随机数
*
* @param randomCount
* int 随机数总长度
* @return String 返回的随机数
*/
private String getRandomString(int nRandomCount) {
/*
* String[] a = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
* "B", "C", "D", "E", "F", "G", "H", "I", "G", "K", "L", "M", "N", "O",
* "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c",
* "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
* "r", "s", "t", "u", "v", "w", "x", "y", "z" };
*/
String[] a = { "a", "b", "c", "d", "e", "f", "g", "h", "g", "k", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
String strRand = "";
int nRand;
// 取其随机数的总数
int LengthOfRandom = a.length;
// 生成随机类
Random random = new Random();
// 循环取随机取其整数,并将其整数所对应的结果进行累加
for (int i = 0; i < nRandomCount; i++) {
nRand = random.nextInt(LengthOfRandom);
strRand += a[nRand];
}
// 返回累加后的结果
return strRand;
}
/**
* 生成其随机的图形
*
* @param width
* int 生成图形的宽度
* @param height
* int 生成图形的高度
* @param nLengthOfRandom
* int 随机码的个数
* @param nDisturbLineCount
* int 干扰线的条数
* @return BufferedImage
*/
public BufferedImage getRandomImage(int nWidth, int nHeight,
int nLengthOfRandom, int nDisturbLineCount)
{
// 在内存中创建图象
BufferedImage image = new BufferedImage(nWidth, nHeight,
BufferedImage.TYPE_INT_RGB);
// 获取图形上下文
Graphics g = image.getGraphics();
String strRand = "";
nLengthOfRandom = (nLengthOfRandom <= 0) ? 6 : nLengthOfRandom;
nDisturbLineCount = (nDisturbLineCount <= 0) ? 0 : nDisturbLineCount;
// 生成随机类
Random random = new Random();
// 设定背景色
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, nWidth, nHeight);
// 设定字体
g.setFont(new Font("Times New Roman", Font.PLAIN, 16));
// 画边框
g.setColor(new Color(255, 255, 255));
g.drawRect(0, 0, nWidth - 1, nHeight - 1);
// 随机产生nDisturbLineCount条干扰线,使图象中的认证码不易被其它程序探测到
g.setColor(getRandColor(160, 200));
for (int i = 0; i < nDisturbLineCount; i++) {
int x = random.nextInt(nWidth);
int y = random.nextInt(nHeight);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
}
// 取随机产生的认证码(6位)
strRand = this.getRandomString(nLengthOfRandom);
// 设置其属性randomString的值
this.strRandomString = strRand;
for (int i = 0; i < nLengthOfRandom; i++) {
// 将认证码显示到图象中
g.setColor(new Color(20 + random.nextInt(110), 20 + random
.nextInt(110), 20 + random.nextInt(110)));
// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
g.drawString(strRand.substring(i, i + 1), 13 * i + 5, 14);
}
// 图象生效
g.dispose();
return image;
}
}