Jquery ajax struts2 user name verification (get)

Source: Internet
Author: User

Jquery ajax struts2 user name verification (get)
Page:
$ (Document). ready (function (){
CheckConfirm ();
});
// Verify whether the user name exists
Function checkConfirm (){
$ ("# UserName"). blur (function (){
Var gradename = $ (this). val ();
Var changeUrl = "<% = path %>/system/SysOperator/checkUserNameAction. action? InputName = "+ gradename;
$. Get (changeUrl, function (str ){
If (str = '1 '){
$ ("# GradeInfo" ).html ("<font color = \" red \ "> the user name you entered exists! Enter again! </Font> ");
} Else {
$ ("# GradeInfo" ).html ("");
}
})
Return false;
})
}

<S: textfield id = "userName" label = "1" name = "userName" maxlength = "16" size = "16"/>
<Font color = "red"> * </font>
<Span id = "gradeInfo"> </span>
Struts2 configuration file:
<! -- User Name verification -->
<Action name = "checkUserNameAction" class = "qxUserAction" method = "checkUserName">
<Result type = "stream">
<Param name = "contentType"> text/html </param>
<Param name = "inputName"> inputStream </param>
</Result>
</Action>
Struts2Action:
Private InputStream inputStream;
Private String inputName;
Public InputStream getInputStream (){
Return inputStream;
}

Public void setInputStream (InputStream inputStream ){
This. inputStream = inputStream;
}

Public String getInputName (){
Return inputName;
}

Public void setInputName (String inputName ){
This. inputName = inputName;
}
 
Public String checkUserName (){
// When the operator name is not blank
If (! StringUtil. isBlank (this. inputName )){
// The Operator name cannot be repeated.
Long operatorNameCount = this. qxUserService
. CheckUserNameExist (this. inputName. trim ());

If (operatorNameCount> 0 ){
InputStream = new StringBufferInputStream ("1 ");
} Else {
InputStream = new StringBufferInputStream ("0 ");
}
}
Return SUCCESS;
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.