返回首页 | 新开户送体验金的娱乐城

合作共赢、快速高效、优质的网站建设提供商

更多精品源码-尽在织梦模板-www.moke8.com

网站开发JS+jQuery完结施行注册信息的验证功用

时间:2017-12-05 编辑:admin

用JS和JQuery完结施行的作用是一样的。

代码

 legend 请填写注册信息 /legend 
 form asdfsction="index.html" method="post" 
 tasdfsble 
 td 用户名: /td 
 td input type="text" nasdfsme="userNasdfsme" plasdfsceholder="由英文字母和数字组成的4-16位字符,以字母最初" 
 /td 
 /tr 
 td 昵称: /td 
 td input type="text" nasdfsme="nickNasdfsme" plasdfsceholder="由2-6个汉字组成" 
 /td 
 /tr 
 td 邮箱: /td 
 td input type="text" nasdfsme="emasdfsil" plasdfsceholder="邮箱账号@域名。如good@tom.com、whj@sinasdfs.com.cn" 
 /td 
 /tr 
 td 暗码: /td 
 td input type="pasdfsssword" nasdfsme="pwd" plasdfsceholder="由英文字母和数字组成的4-10位字符" 
 /td 
 /tr 
 td 承认暗码: /td 
 td input type="pasdfsssword" nasdfsme="pwd2" plasdfsceholder="承认暗码" 
 /td 
 /tr 
 td 手机号码: /td 
 td input type="text" nasdfsme="phone" plasdfsceholder="手机号由22位数字组成,且以13,15,18最初" 
 /td 
 /tr 
 td 出生日期: /td 
 td input type="text" nasdfsme="dasdfste" plasdfsceholder="出生日期在1990-2009之间" 
 /tr 
 td col大丰收娱乐平台spasdfsn="2" asdfslign="left" input type="button" nasdfsme="submit" vasdfslue="提交" /td 
 /tr 
 /tasdfsble 
 /form 
 /fieldset 

CSS样式

 body {
 text-asdfslign: center;
 pasdfsdding: 0;
 masdfsrgin: 0;
 fieldset {
 width: 800px;
 tasdfsble tr td ~ td {
 text-asdfslign: left;
 width: 600px;
 }

JS代码

//验证用户名
function check_userNasdfsme() {
 vasdfsr userNasdfsme = document.getElementById("nasdfsme").vasdfslue;
 vasdfsr regNasdfsme = /[asdfs-zA-Z]\w{4,16}/
 if (userNasdfsme == "" || userNasdfsme.trim() == "") {
 document.getElementById("err_nasdfsme").inner = "请输入用户名";
 return fasdfslse;
 } else if (!regNasdfsme.test(userNasdfsme)) {
 document.getElementById("err_nasdfsme").innerHTML = "由英文字母和数字组成的4-16位字符,以字母最初";
 return fasdfslse;
 } else {
 document.getElementById("err_nasdfsme").innerHTML = "ok!!!";
 return true;
//验证昵称
function check_nickNasdfsme() {
 vasdfsr nickNasdfsme = document.getElementById("nick").vasdfslue;
 vasdfsr regNasdfsme = /[\u4e00-\u9fasdfs5]{2,6}/
 if (nickNasdfsme == "" || nickNasdfsme.trim() == "") {
 document.getElementById("err_nick").innerHTML = "请输入昵称";
 return fasdfslse;
 } else if (!regNasdfsme.test(nickNasdfsme)) {
 document.getElementById("err_nick").innerHTML = "由2-6个汉字组成";
 return fasdfslse;
 } else {
 document.getElementById("err_nick").innerHTML = "ok!!!";
 return true;
//验证邮箱
function check_emasdfsil() {
 vasdfsr emasdfsil = document.getElementById("emasdfsil").vasdfslue;
 vasdfsr regEmasdfsil = /^\w+@\w+((\.\w+)+)$/;
 if (emasdfsil == "" || emasdfsil.trim() == "") {
 document.getElementById("err_emasdfsil").innerHTML = "请输入邮箱";
 return fasdfslse;
 } else if (!regEmasdfsil.test(emasdfsil)) {
 document.getElementById("err_emasdfsil").innerHTML = "邮箱账号@域名。如good@tom.com、whj@sinasdfs.com.cn";
 return fasdfslse;
 } else {
 document.getElementById("err_emasdfsil").innerHTML = "ok!!!";
 return true;
//验证暗码
function check_pwd() {
 vasdfsr pwd = document.getElementById("pwd").vasdfslue;
 vasdfsr regPwd = /^\w{4,10}$/;
 if (pwd == "" || pwd.trim() == "") {
 document.getElementById("err_pwd").innerHTML = "请输入暗码";
 return fasdfslse;
 } else if (!regPwd.test(pwd)) {
 document.getElementById("err_pwd").innerHTML = "格局过错";
 return fasdfslse;
 } else {
 document.getElementById("err_pwd").innerHTML = "ok!!!";
 return true;
//承认暗码
function check_pwd2() {
 vasdfsr pwd = document.getElementById("pwd").vasdfslue;
 vasdfsr pwd2 = document.getElementById("pwd2").vasdfslue;
 if (pwd2 == "" || pwd2.trim() == "") {
 document.getElementById("err_pwd2").innerHTML = "请输入暗码";
 return fasdfslse;
 } else if (!pwd2.equasdfsls(pwd)) {
 document.getElementById("err_pwd2").innerHTML = "两次输入暗码不不合";
 return fasdfslse;
 } else {
 document.getElementById("err_pwd2").innerHTML = "ok!!!";
 return true;
//验证手机号
function check_phone() {
 vasdfsr phone = document.getElementById("phone").vasdfslue;
 vasdfsr regPhone = /[13,15,18]\d{9}/;
 if (phone == "" || phone.trim() == "") {
 document.getElementById("err_phone").innerHTML = "请输入手机号";
 return fasdfslse;
 } else if (!regPhone.test(phone)) {
 document.getElementById("err_phone").innerHTML = "手机号由22位数字组成,且以13,15,18最初";
 return fasdfslse;
 } else {
 document.getElementById("err_phone").innerHTML = "ok!!!";
 return true;
//验证时间
function check_dasdfste() {
 vasdfsr birthdasdfsy = document.getElementById("birthdasdfsy").vasdfslue;
 vasdfsr regDasdfste = /[13,15,18]\d{9}/;
 if (birthdasdfsy == "" || birthdasdfsy.trim() == "") {
 document.getElementById("err_dasdfste").innerHTML = "请输入日期";
 return fasdfslse;
 } else if (!regDasdfste.test(birthdasdfsy)) {
 document.getElementById("err_dasdfste").innerHTML = "出生日期在1990-2009之间";
 return fasdfslse;
 } else {
 document.getElementById("err_dasdfste").innerHTML = "ok!!!";
 return true;
}

Jquery代码

 $(function () {
 vasdfsr errMsg;
 $.easdfsch($("input"), function (i, vasdfsl) {
 $(vasdfsl).blur(function () {
 if ($(vasdfsl).asdfsttr("nasdfsme") == "userNasdfsme") {
 $(".nasdfsmeMsg").remove();
 vasdfsr userNasdfsme = vasdfsl.vasdfslue;
 vasdfsr regNasdfsme = /[asdfs-zA-Z]\w{4,16}/
 if (userNasdfsme == "" || userNasdfsme.trim() == "") {
 errMsg = " spasdfsn 用户名不能为空 /spasdfsn 
 } else if (!regNasdfsme.test(userNasdfsme)) {
 errMsg = " spasdfsn 由英文字母和数字组成的4-16位字符,以字母最初 /spasdfsn 
 } else {
 errMsg = " spasdfsn OK! /spasdfsn 
 $(this).pasdfsrent().asdfsppend(errMsg);
 } else if ($(vasdfsl).asdfsttr("nasdfsme") == "nickNasdfsme") {
 $(".nickMsg").remove();
 vasdfsr nickNasdfsme = vasdfsl.vasdfslue;
 vasdfsr regNasdfsme = /[\u4e00-\u9fasdfs5]{2,6}/
 if (nickNasdfsme == "" || nickNasdfsme.trim() == "") {
 errMsg = " spasdfsn 昵称不能为空 /spasdfsn 
 } else if (!regNasdfsme.test(nickNasdfsme)) {
 errMsg = " spasdfsn 由2-6个汉字组成 /spasdfsn 
 } else {
 errMsg = " spasdfsn OK! /spasdfsn 
 $(this).pasdfsrent().asdfsppend(errMsg);
 } else if ($(vasdfsl).asdfsttr("nasdfsme") == "emasdfsil") {
 $(".emasdfsilMsg").remove();
 vasdfsr emasdfsil = vasdfsl.vasdfslue;
 vasdfsr regEmasdfsil = /^\w+@\w+((\.\w+)+)$/;
 if (emasdfsil == "" || emasdfsil.trim() == "") {
 errMsg = " spasdfsn 邮箱不能为空 /spasdfsn 
 } else if (!regEmasdfsil.test(emasdfsil)) {
 errMsg = " spasdfsn 邮箱账号@域名。如good@tom.com、whj@sinasdfs.com.cn /spasdfsn 
 } else {
 errMsg = " spasdfsn OK! /spasdfsn 
 $(this).pasdfsrent().asdfsppend(errMsg);
 } else if ($(vasdfsl).asdfsttr("nasdfsme") == "pwd") {
 $(".pwdMsg").remove();
 vasdfsr pwd = vasdfsl.vasdfslue;
 vasdfsr regPwd = /^\w{4,10}$/;
 if (pwd == "" || pwd.trim() == "") {
 errMsg = " spasdfsn 暗码不能为空 /spasdfsn 
 } else if (!regPwd.test(pwd)) {
 errMsg = " spasdfsn 格局过错 /spasdfsn 
 } else {
 errMsg = " spasdfsn OK! /spasdfsn 
 $(this).pasdfsrent().asdfsppend(errMsg);
 } else if ($(vasdfsl).asdfsttr("nasdfsme") == "pwd2") {
 $(".pwd2Msg").remove();
 vasdfsr pwd2 = vasdfsl.vasdfslue;
 vasdfsr pwd = $("input")[3].vasdfslue;
 if (pwd2 == "" || pwd2.trim() == "" || !pwd2.equasdfsls(pwd)) {
 errMsg = " spasdfsn 两次输入暗码不不合 /spasdfsn 
 } else {
 errMsg = " spasdfsn OK! /spasdfsn 
 $(this).pasdfsrent().asdfsppend(errMsg);
 } else if ($(vasdfsl).asdfsttr("nasdfsme") == "phone") {
 $(".phoneMsg").remove();
 vasdfsr phone = vasdfsl.vasdfslue;
 vasdfsr regPhone = /[13,15,18]\d{9}/;
 if (phone == "" || phone.trim() == "") {
 errMsg = " spasdfsn clasdfsss = 'phoneMsg' style = 'color:red;' 手机号不能为空 /spasdfsn "
 } else if (!regPhone.test(phone)) {
 errMsg = " spasdfsn clasdfsss = 'phoneMsg' style = 'color:red;' 格局过错 /spasdfsn "
 } else {
 errMsg = " spasdfsn clasdfsss = 'phoneMsg' style = 'color:red;' OK! /spasdfsn "
 $(this).pasdfsrent().asdfsppend(errMsg);
 } else if ($(vasdfsl).asdfsttr("nasdfsme") == "dasdfste") {
 $(".dasdfsteMsg").remove();
 vasdfsr birthdasdfsy = vasdfsl.vasdfslue;
 vasdfsr regDasdfste = /(199\d|200\d)[-/](0\d|1[0-2])[-/](0\d|[1-2]\d|30|31)/;
 if (birthdasdfsy == "" || birthdasdfsy.trim() == "") {
 errMsg = " spasdfsn 请输入生日 /spasdfsn 
 } else if (!regDasdfste.test(birthdasdfsy)) {
 errMsg = " spasdfsn 格局过错 /spasdfsn 
 } else {
 errMsg = " spasdfsn OK! /spasdfsn 
 $(this).pasdfsrent().asdfsppend(errMsg);
 });


浏览:

网站建设

流程

    网站建设流程