日期:2014-05-16 浏览次数:20628 次
boolean validate = userService.validateUserName(username); out.print(validate);
function validate(){ var username = $("#username").val(); $.ajax({url:"/XXX/userManager",cache:false,type:"POST",data:"type=vali&username="+username,success:function(data){ if(data=="true"){ var div = document.getElementById("valiDiv"); div.style.display = "block"; }else{ alert("此用户已存在!"); $("#username").val(""); } }}); } function clearDiv(){ var div = document.getElementById("valiDiv"); div.style.display = "none"; } <div id="valiDiv" style=" position:absolute;top:65px;left:550px; width:150px; height:15px; font-size:13; color:#33FF00; font-weight:bold; text-align:center; display:none;"><img src="<%=path %>/images/right.gif" width="15px" height="15px" /> 此用户名可以使用</div> <form name="aform" method="post" > <table width="100%" border="0" cellpadding="0" cellspacing="1" id="ConTable"> <tr> <td align="right">用户名:</td> <td><input type="text" name="username" id="username" onBlur="validate()" onFocus="clearDiv()" /><FONT color="red">*</FONT></td> </tr></table> </form>