㈠ 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;
}
}