Use Jquery.validationengine Ajax to verify that the background ID exists
Front-desk jquery validation Framework Validation
Jsp:
<link rel= "stylesheet" type= "Text/css" href= "<%=path%>/js/css/validationengine.jquery.css"/>
< Script type= "Text/javascript" src= "<%=path%>/js/jquery/jquery-1.4.2.min.js" ></script>
< Script type= "Text/javascript" src= "<%=path%>/js/validation/jquery.validationengine-cn.js" ></script >
<script type= "Text/javascript" src= "<%=path%>/js/validation/jquery.validationengine.js" > </script>
<input type= "text" name= "Item.entry" id= "Item_entry" class= "validate[required,custom[" onlynumber],ajax[ajaxitemnocall],length[0,4]] text-input "size="/></td>
Jquery.validationengine-cn.js
"Ajaxitemnocall": {
"url": "Validateitemno",
"Alerttext": "* ID already used",
"Alerttextok": "*id can use",
" Alerttextload ":" * check, please wait ... "
}
Itemaction.java
@Action (results = {@Result (type= "JSON")}, params = {"Excludeproperties", "Validatereturn"}, value= "
Validateitemno ") Public String Validateitemno () throws exception{actioncontext ct = actioncontext.getcontext (); HttpServletRequest request= (httpservletrequest) ct.get (Servletactioncontext.
Http_request);
String Validateid = Request.getparameter ("FieldID");
String Validatevalue = Request.getparameter ("Fieldvalue");
int valivalue = Integer.parseint (Validatevalue);
Item = Itemservice.finditembyid (Valivalue);
if (Item.getentry ()!= valivalue) {validatereturn[0] = Validateid;
Validatereturn[1] = true;
VALIDATERETURN[2] = "can be used";
}else {validatereturn[0] = Validateid;
VALIDATERETURN[1] = false;
VALIDATERETURN[2] = "already exists in the specified ID";
Return to "success"; }