Home Web Front-end JS Tutorial A small example of JQuery implementing user name non-refresh verification_jquery

A small example of JQuery implementing user name non-refresh verification_jquery

May 16, 2016 pm 05:39 PM
jquery No refresh verify

1. Add text boxes, styles and js script references to the static page:

Copy code The code is as follows:

Code highlighting produced by Actipro CodeHighlighter (freeware)http:/ /www.jb51.net/-->
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat=" server">
<title>Untitled page</title>
<script language ="javascript" src ="../jquery-1.3.2.min.js" type ="text /javascript" ></script>
<script language ="javascript" src ="validator.js" type ="text/javascript" ></script>
<link type = "text/css" rel="stylesheet" href ="validator.css" />
</head>
<body>
  <form id="form1" runat="server ">
                         < </div>
  </div>
  </form>
</body>
</html>


2.css style sheet, when the text box text is empty, the border is red:

.txtName
{
border:1px red solid;
}

3.js script: When the text box text is empty, the border is red; if the user name is janes, it will prompt "the user name already exists", otherwise it will prompt "the user name can be used".

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.jb51.net/-->$(function(){var txtname=$("#txtName");

/ /Text box style when entering text
txtname.keyup(function(){
var name=$(this).val();
if(name=="")
$(this ).addClass("txtName");
else $(this).removeClass("txtName");
})
//Verify whether the username is available when losing focus
$("# txtName").blur(function()
{
var name=$(this).val();
$.get("validator1.aspx?name=" name,null,function(response ){
$("#result").html(response);
})

})

})



4..aspx and .cs page codes are used to verify whether the user name is available to return the result.

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.jb51.net/-->public partial class Validator_validator1 : System.Web.UI.Page{

protected void Page_Load(object sender, EventArgs e)
{
string name = Request.QueryString["name"].ToString();
if (name == "janes")
Response.Write("This user Name already exists! ");
else
Response.Write("This username can be used!");

}
}


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed method to unblock using WeChat friend-assisted verification Detailed method to unblock using WeChat friend-assisted verification Mar 25, 2024 pm 01:26 PM

Detailed method to unblock using WeChat friend-assisted verification

New features in PHP 8: Added verification and signing New features in PHP 8: Added verification and signing Mar 27, 2024 am 08:21 AM

New features in PHP 8: Added verification and signing

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

How to solve the problem of steam login stuck in mobile token verification? How to solve the problem of steam login stuck in mobile token verification? Mar 14, 2024 pm 07:35 PM

How to solve the problem of steam login stuck in mobile token verification?

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

PHP calculates MD5 hash value of string PHP calculates MD5 hash value of string Mar 21, 2024 am 10:51 AM

PHP calculates MD5 hash value of string

See all articles