Jqueryajaxstruts2 user name verification (get) page: $ (document ). ready (function () {checkConfirm () ;}); // verify whether the user name has functioncheckConfirm () {$ (& quot; # userName & quot ;). blur (function () {vargrade
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 ("the user name you entered exists! Enter again! ");
} Else {
$ ("# GradeInfo" ).html ("");
}
})
Return false;
})
}
*
Struts2 configuration file:
Text/html
InputStream
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;
}