jquery registration verification

funCheck [0] = function (str) (/ / account number
if (isNotNull (str))
(Return 0;)
else (return 1;)
)
funCheck [1] = function (str) (/ / nickname
if (isNotNull (str)) (
return 0;
)
else (return 1;)
)
funCheck [2] = function (str) (/ / email
if (isEmail (str))
(Return 0;)
else (return 1;)
)
funCheck [3] = function (str) (/ / Tel
if (isTel (str) | | isPhone (str))
(Return 0;)
else (return 1;)
)
//--------
funCheck [4] = function (str) (/ / password
if (isNotNull (str))
(Return 0;)
else (return 1;)

)

funCheck [5] = function (str) (/ / Confirm Password
if (isNotNull (str)) (
if ($("# passwd1 "). val () == $ (" # passwd2 "). val ()) (
return 0;
) Else (
return 2;
)
)
else (return 1;)
)
funCheck [6] = function (str) (/ / password prompt problem
if (str == null | | str == "") (return 1;) else (
if (isSmall (str, 20)) (return 0;)
else (return 2;)
)
)
funCheck [7] = function (str) (/ / password prompt answer
if (str == null | | str == "") (return 1;) else (
if (isSmall (str, 20)) (return 0;)
else (return 2;)
)
)
//------------
funCheck [8] = function (str) (/ / real name

return 0;
)
funCheck [9] = function (str) (/ / Age
if (str == "" | | str == null) (return 0;)
if (str> 0 & & str <100) (return 0;) else (return 1;)
)
funCheck [10] = function (str) (/ / Personal Home
return 0;
)
funCheck [11] = function (str) (/ / qq
return 0;
)
funCheck [12] = function (str) (/ / Introduction
if (isSmall (str, 100))
(Return 0;)
else (return 1;)
)

$ (Document). Ready (function () (
var uid = false;

/ * This part is to realize the time to select a different input, display different prompts * /
$ (". Text_01"). Focus (function () (
/ / Alert ($ (this). Parent (). Next ("div"). Attr ("class"));
$ (This). Parent (). Next ("div"). Html (msgInfo [$(". text_01 "). Index ($ (this) [0])] [0]);
$ (This). Parent (). Next ("div"). RemoveClass ();
$ (This). Parent (). Next ("div"). AddClass ("tips2");
));
$ (". Text_01"). Blur (function () (
/ / Alert ($ (this). Parent (). Next (). Html ());

$ (This). Parent (). Next ("div"). Html ("");
$ (This). Parent (). Next ("div"). RemoveClass ();
/ / Alert ($ (this). Attr ("id"));
if ($ (this). attr ("id") == "usrname") (

if (isNotNull (this.value)) (/ / if the user name is not empty
if (isSmall (this.value, 6)) / / If the user name is less than 6
(
$ (This). Parent (). Next ("div"). RemoveClass ();
$ (This). Parent (). Next ("div"). AddClass ("wrong");
$ (This). Parent (). Next ("div"). Html ("<img src='../img/zhaoshang2/zhao2_06.gif' border='0' />" + msgInfoUID [4]);
/ / $ (This). Parent (). Next ("div"). Html (msgInfoUID [4]);

uid = false;

)
else (
if (isUID (this.value)) (
var flag = 0;
/ / Alert (1);
var murl = ".. / ashx / RegisterCheck.ashx? & name =" + encodeURI ($("# usrname "). val ());
$. Ajax (
(
type: "GET",
url: murl,
data: "",
/ / Async: false, / / synchronous request, the request only after the completion of other operations can be carried out
success: function (result) (

var isUsed = result;
/ / Alert (isUsed);
if (isUsed == "false") (/ / can be registered
/ / Alert ("can register");
$($("# Usrname ")). Parent (). Next (" div "). RemoveClass ();
$($("# Usrname ")). Parent (). Next (" div "). Html (msgInfoUID [3]);
$($("# Usrname ")). Parent (). Next (" div "). AddClass (" right ");
uid = true;
/ / Alert (isUsed);
)
else (/ / user name has been registered
/ / Alert ("user name has been registered");
/ / Alert ($(". text_01 "). Index ($ (this) [0]));
$($("# Usrname ")). Parent (). Next (" div "). RemoveClass ();
$($("# Usrname ")). Parent (). Next (" div "). AddClass (" wrong ");
$($("# Usrname ")). Parent (). Next (" div "). Html (" <img src='../img/zhaoshang2/zhao2_06.gif' border='0' /> "+ msgInfoUID [2]);
/ / Alert ($ (this). Parent (). Next ("div"). Attr ("class"));
/ / Alert ($ (this). Html ());
uid = false;
)
)
));

)
else (
/ / Alert (2);
$($("# Usrname ")). Parent (). Next (" div "). RemoveClass ();
$($("# Usrname ")). Parent (). Next (" div "). Html (msgInfoUID [0]);
$($("# Usrname ")). Parent (). Next (" div "). AddClass (" wrong ");
uid = false;
)
)
)
else (
/ / Alert (3);
$($("# Usrname ")). Parent (). Next (" div "). RemoveClass ();
$($("# Usrname ")). Parent (). Next (" div "). Html (msgInfoUID [1]);
$($("# Usrname ")). Parent (). Next (" div "). AddClass (" wrong ");
uid = false;
)

)
if (funCheck [$(". text_01 "). index ($ (this) [0 ])]($( this) [0]. value) == 0) (
/ / Alert (4);
if ($(". text_01 "). index ($ (this) [0])! = 0 & & $ (". text_01 "). index ($ (this) [0])! = -1) (

/ / Alert (5);
$ (This). Parent (). Next ("div"). RemoveClass ("wrong");
$ (This). Parent (). Next ("div"). RemoveClass ("tips2");
)
)
else (
/ / Alert (2);
/ / / Alert ($(". text_01 "). Index ($ (this) [0]));
$ (This). Parent (). Next ("div"). Html ("<img src='../img/zhaoshang2/zhao2_06.gif' border='0' />" + msgInfo [$(". text_01 "). index ($ (this) [0])] [funCheck [$(". text_01"). index ($ (this) [0 ])]($( this) [0]. value)]) ;
$ (This). Parent (). Next ("div"). AddClass ("wrong");

)
/ / Alert (funCheck [$(". kinput "). Index ($ (this) [0 ])]($( this) [0]. Value));
));

/ * Whether there is authentication * /

$ ("# Submit_butt"). Click (function () (/ / click the error when the authentication data is not all legal, if all legal, then submit, or else return false;
var isCheck = true;
/ / Alert (0);

$ (". Text_01"). Each (function (j) (
if (j <= 7)
$($(". Text_01 "). Get (j)). Blur ();
));
$ (". Wrong"). Each (function (i) (
isCheck = false;
));
/ / If ($("# usrname "). Val () ==" ") (
/ / IsCheck = false
/ /)
if (isCheck == false) (
alert ("Please fill in the requested zone (*) Number of items");
)

return isCheck;
))
/ / $ (Document). Click (function () (
/ / / / $ ("# Wrap"). Show (5000);
/ / / / $ ("# Wrap"). FadeOut (1000);
/ /))
))
</ Script>

</ Form>
</ Body>
</ Html>
<script language="javascript" type="text/javascript" src="../JS/check.js"> </ script> this file is as follows

/ *
Limit the number of bits input characters
str is the user input string, len is to limit the number of bits
----------------------------
* /
function isSmall (str, len) (
if (str.length <len) (
return (true);
) Else (
return (false);
)
)

/ * Check the consistency of the two strings
---------------------------------
* /
function isSame (str1, str2) (
if (str1 == str2) (
return (true);
) Else (
return (false);
)
)

/ *
Determine whether the empty string start
---------------------------------
* /
function isNotNull (str) (
if (str.length ==""){
return (false);
) Else (
return (true);
)
)
/ *
Judgement is not a mobile phone number
---------------------------------
* /
function isPhone (str) (

reg = / ^ [0]? 13 \ d (9) $ / gi;
reg2 = / ^ [0]? 15 \ d (9) $ / gi;
if (! reg.test (str) & &! reg2.test (str)) (
return false;
)
return true;
)
/ *
Determine whether the user name contains characters (user name can not be Chinese, but also with special characters are not allowed)
Note:
Regular expressions. Test () method is used to detect whether a string matches a pattern
---------------------------------
* /
function notChinese (str) (
var reg = / [^ A-Za-z0-9_] / g
if (reg.test (str)) (
return (false);
) Else (
return (true);
)
)

/ *
Determine whether the date
----------------------------------
* /
function isDate (theStr) (
var the1st = theStr.indexOf ('-');
var the2nd = theStr.lastIndexOf ('-');

if (the1st == the2nd) (
return (false);
)
else (
var y = theStr.substring (0, the1st);
var m = theStr.substring (the1st +1, the2nd);
var d = theStr.substring (the2nd +1, theStr.length);
var maxDays = 31;

if (fucCheckNUM (m) == false | | fucCheckNUM (d) == false | | fucCheckNUM (y) == false) (
return (false);)
else if (y.length <4) (return (false);)
else if ((m <1) | | (m> 12)) (return (false);)
else if (m == 4 | | m == 6 | | m == 9 | | m == 11) maxDays = 30;
else if (m == 2) (
if (y% 4> 0) maxDays = 28;
else if (y% 100 == 0 & & y% 400> 0) maxDays = 28;
else maxDays = 29;
)
if ((m <1) | | (m> maxDays)) (return (false);)
else (return (true);)
)
)
/ *
Determine whether the number of
---------------------------------------
* /
function isNum (num) (
var i, j, strTemp;
strTemp = "0123456789";
if (num.length == 0) (
return false;
)
for (i = 0; i <num.length; i + +) (
j = strTemp.indexOf (num.charAt (i));
if (j ==- 1) (/ / specifying the number of characters is not
return false;
)
)

return true; / / note numbers
)

/ *
Determine whether a fixed number of bits

-------------------------
* /
function isAtn (str, n) (
if (str.length! = n) (
return (false);
)
else (
return (true);
)
)

/ *
Determine whether the telephone number for the beginning (completed)
--------------------------
* /
function isTel (telstr)
(
var reg1 = / (\ (\ d (3) \) | \ d (3) -)? \ d (8) / g; / / 8 phone numbers
var reg2 = / (\ (\ d (3) \) | \ d (3) -)? \ d (7) / g; / / 7 phone number
if (telstr !="") (
if (reg1.test (telstr) | | reg2.test (telstr)) (
return (true);
)
else (
return (false);
)
) Else (return (false);)
)

/ *
Determine whether the email 【simple to verify whether the @ and.】 (Completed)
---------------------------
* /
function isEmail (emailstr) (
/*-------------------
if ((emailstr.indexOf ('@', 0) == -1) | | emailstr.indexOf ('.') == -1) (
return false;
)
else (
return true;
)
---------------------*/
var reg = / \ w +([-+.'] \ w +) * @ \ w +([-.] \ w +) * \. \ w +([-.] \ w +) * / i;
if (emailstr !="") (
if (reg.test (emailstr)) (
return (true);
)
else (
return (false);
)
)
else (
return (false);
)
)
/ *
Determine whether the Postal Code
---------------------------
* /
function isPostCode (str) (
var reg = / \ d (6) / g;
if (str !="") (
if (reg.test (str)) (
return (true);
)
else (
return (false);
)
)
else (
return (false);
)
)

/ *
Chinese character input judge
---------------------------
* /
function isChinese (str) (
/ / If the value is empty, do not pass validation
if (str == "")
return false;
var pattern = / ^ ([\ u4E00-\ u9FA5] | [\ uFE30-\ uFFA0 ])*$/ gi;
if (pattern.test (str))
return true;
else
return false;
)
/ * Determine the user name was included in the case alphanumeric and _ * /
function isUID (str) (
var jgpattern = / ^ [A-Za-z0-9_ ]+$/;
var huzhaocard = str;
if (! jgpattern.test (huzhaocard))
(
return false;
)
else
(
return true;
)
)
/ / Check is not at
function isHttp (str)
(
var pattern = / ^ (http: \ / \ /)? [a-zA-Z0-9-] + (\. [a-zA-z0-9-] +) + \ /? $ / gi;
if (pattern.test (str))
(

return true;
)
else
(
return false;
)
)

分类:Web 时间:2010-04-25 人气:440
分享到:
blog comments powered by Disqus

相关文章

  • NVL (a, b) function if a = null, return b 2010-10-14

    NVL (a, b) function if a = null, return b

  • javaBean instance of registration verification 2011-01-13

    First define the Bean: package com.keith.bean; import java.util.HashMap; import java.util.Map; public class Register { private String name; private String age; private String email; private Map<String, String> errors = null; public Register() { this

  • Ajax registration verification 2009-09-07

    <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK" /> <title>Ajax</title> <script type="text/javascript"> var xmlobj; // Define the XMLHttpRequest object functio

  • Trie-dictionary tree (the word tree) Basic application 2010-05-12

    #include <stdio.h> #include <stdlib.h> #include <string.h> int const N= 1000000; struct Trie{ int id; // Tag each one word int cnt; // The number of marked word prefix int next[26]; // 26 A child node void init(){ [N]; int num= 0, root=

  • flex datagrid in numerical order, alphabetical, date sort order 2010-10-29

    flex only support the default sort order string and numer two, read data from the database to the flex front-end, very often could have been converted to Strng Number type type, so order into chaos. One way to write himself a sort of clicking on the

  • HTML.JS.JSON special characters 2010-12-13

    JS to convert HTML special characters These days to do the project, found that in JSON format from the server to pass data to the client, by JS displayed in HTML pages, there are some special characters can not be directly displayed as the background

  • C++实现将一个字符串中的字符替换成另一个字符串的方法 2014-03-12

    这篇文章主要介绍了C++实现将一个字符串中的字符替换成另一个字符串的方法,需要考虑的情况比较全面,有不错的借鉴价值,需要的朋友可以参考下 本文实例讲述了C++实现将一个字符串中的字符替换成另一个字符串的方法,分享给大家供大家参考.具体方法如下: 题目要求: 原地实现字符串中的每个空格替换成"%20",例如输入"We are happy", 输出"We%20are%20happy" 被替换的字符串当然不仅仅是空格,上面只是个例子 这是道很好的题目,

  • Java制作智能拼图游戏原理及代码 2014-04-28

    本文给大家分享的是使用Java实现智能拼图游戏的原理,以及实现的源码,推荐给大家,有需要的小伙伴可以参考下. 今天突发奇想,想做一个智能拼图游戏来给哄女友. 需要实现这些功能 第一图片自定义 第二宫格自定义,当然我一开始就想的是3*3 4*4 5*5,没有使用3*5这样的宫格. 第三要实现自动拼图的功能,相信大家知道女人耍游戏都不是很厉害,所以这个自动拼图功能得有. 其他什么暂停.排行就不写了! 现在重点问题出来了 要实现自动拼图功能似乎要求有点高哦!计算机有可不能像人一样只能: 先追究下本质

  • 基于一致性hash算法 C++语言的实现详解 2014-09-19

    在<基于一致性hash算法(consistent hashing)的使用详解>一文中已经介绍了一致性hash的基本原理,本文将会对其具体实现细节进行描述,并用c++语言对一致性hash进行了简单的实现 一致性hash算法实现有两个关键问题需要解决,一个是用于结点存储和查找的数据结构的选择,另一个是结点hash算法的选择. 首先来谈一下一致性hash算法中用于存储结点的数据结构.通过了解一致性hash的原理,我们知道结点可以想象为是存储在一个环形的数据结构上(如下图),结点A.B.C.D按has

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.195 (s). 12 q(s)