js进行有效性验证

1.reg.jsp
<% @ page language = " java "   import = " java.util.* "  pageEncoding = " UTF-8 " %>
< html >
< head >
    
< title > reg </ title >
    
< script language = javascript >
function check_admin()

   window.demo.location.href
="checkadmin.jsp?admin="+document.all.admin.value;  
}

function show_rpt(tag)
if(tag==0)
   document.all.rpt.innerHTML
="<font color=#00AA00>可用</font>";
   
else
   document.all.rpt.innerHTML
="<font color=#FF0000>已经存在,不可用</font>";
}

</ script >
</ head >
< body >  
< table >< tr >
   
< td >  登陆名: </ td >< td >< input type = text name = " admin "  onBlur = " check_admin(); " />< html:errors property = " admin " />
    
< span ID = rpt >   </ span >
   
< input type = button value = " 是否可用 "  onclick = " check_admin(); " /></ td >
   
</ tr >
   
</ table >
   
< iframe name = " demo "  ID = " demo "  width = 95 %  height = 0  frameborder = 0  src = "" ></ iframe >
</ body >
</ html >


2.checkadmin.jsp
<% @ page language = " java "  pageEncoding = " UTF-8 " %>
<%
String admin
= request.getParameter( " admin " );
System.out.println(admin);
if (admin == null || admin.length() < 1 ) return ;
if (admin.equals( " admin " ))
{ out.print("<script language=javascript>window.parent.show_rpt(1);</script>");
}

else
{ out.print("<script language=javascript>window.parent.show_rpt(0);</script>");
}

%>

你可能感兴趣的:(js进行有效性验证)