In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use JQUERY to write registration verification. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
1 compatible with IE678
2 suitable for website development
Html:
$(function () {)
/ / user name loses focus
$("# userName"). On ("keyup blur", function () {
UserNameCheck ()
});
/ / the password loses focus
$("# pwd"). On ("keyup blur", function () {
PwdCheck ()
});
/ / confirm that the password is out of focus
$("# pwdConfirm"). On ("keyup blur", function () {
PwdConfirmCheck ()
});
/ / the mailbox loses focus
$("# email"). On ("keyup blur", function () {
EmailCheck ()
});
/ / submit
$("# reg") .click (function () {
If (userNameCheck ()) = = false | | pwdCheck () = = false | | pwdConfirmCheck () = = false | | emailCheck () = = false)
{
/ / alert ("check form")
Return
}
Else {
$.ajax ({
Type: "post"
Url: "Submit.aspx"
Data: $(form) .serialize ()
Success: function (response,status,xhr) {
If (response== "success")
{
Alert ("Registration successful!")
_ window.location = "HtmlPage1.html"
}
Else {
Alert ("Registration failed!")
}
}
Error: function () {
Alert ("ajax error")
}
});
}
});
$(document) .ajaxStart (function () {
("# div1") .show ()
}) .ajaxStop (function () {
("# div1") .hide ()
});
});
/ / verify the mailbox format
Function checkEmail (str) {
Var re = / ^ (\ wmurf *) + @ (\ wmurf?) + (\.\ w {2,}) + $/
If (re.test (str)) {
Return true
}
Else {
Return false
}
}
Function userNameCheck () {
Var userName = $("# userName") .val ()
/ / user name cannot be empty
If (userName = "") {
$("# label_UserName") .html ("user name cannot be empty!")
/ / $("# userName") [0] .focus ()
Return false
}
Else {
$.ajax ({
Type: "post"
Url: "Ajax.aspx"
Data: $.param ({userName: $("# userName") .val ()})
Success: function (response, status, xhr) {
If (response = = "ok") {
("# label_UserName"). Html ('
')
Return true
}
Else {
$("# label_UserName") .html ("user name already exists!")
Return false
}
}
});
}
}
Function pwdCheck () {
Var pwd = $("# pwd") .val ()
If (pwd = "") {
$("# lable_pwd") .html ("password cannot be empty!")
/ / $("# pwd") [0] .focus ()
Return false
}
Else {
If (pwd.length
< 6) { $("#lable_pwd").html("密码不能少于6位!"); return false; } else { $("#lable_pwd").html('')
Return true
}
}
}
Function pwdConfirmCheck () {
Var pwdConfirm = $("# pwdConfirm") .val ()
If (pwdConfirm = "") {
$("# label_pwdConfirm") .html ('confirm password cannot be empty!')
Return false
}
Else {
If ($("# pwdConfirm") .val ()! = $("# pwd") .val ()) {
$("# label_pwdConfirm") .html ('the password entered twice is not the same, please re-enter it!')
Return false
}
Else {
("# label_pwdConfirm"). Html ('
')
Return true
}
}
}
Function emailCheck () {
Var email = $("# email") .val ()
If (email = "") {
$("# label_email") .html ('mailbox cannot be empty!')
Return false
}
Else {
If (checkEmail (email) = = false) {
$("# label_email") .html ('incorrect mailbox format!')
Return false
}
Else {
("# label_email"). Html ('
')
Return true
}
}
}
# div1 {
Width: 180px
Height: 140px
Display: none
Font-weight: bold
Color: red
}
User name:
*
Password:
*
Confirm password:
*
Mailbox:
*
It is being submitted. Please wait a moment.
On "how to use JQUERY to write registration verification" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.