|
|
Geplaatst op 24-12-2014 02:28:19
|
|
|
|

[mw_shl_code=javascript,true]$(function(){ $("#userName").blur(function() { var value = $("#userName").val(); verifyUserName(value); }); $("#userName").focus(function() { $("#userNameErr").text(""); }); });
function verifyUserName(userName){ var value = $("#userName").val(); $.ajax({ type:"GET", cache:false, async:false, url:"/bookShopping/UserServlet", data:{method:"verifyUserName",userName:value}, dataType:"json", succes:functie(resultaat){ if(result.ifreg =="waar"){ $("#userNameErr").text("Deze gebruikersnaam is geregistreerd!") ); } } }); }[/mw_shl_code]
[mw_shl_code=Java, waar] <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE HTML PUBLIEK "-//W3C//DTD HTML 4.01 Transitioneel//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>
<title>Registratiepagina</title>
<meta HTTP-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="Dit is mijn pagina"> <script type="text/javascript" src="<c:url value='/jquery/jquery-1.5.1.js'/>"></script> <script type="text/javascript" src="<c:url value='/js/register.js'/>"></script> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <script type="text/javascript"> functie _hyz() { $("#vCode").attr("src", '<c:url value='/VerifyCodeServlet?'/>' + nieuwe Date().getTime());
} </script> </head>
<body> <form action="/bookShopping/UserServlet"> <invoertype="verborgen" naam="methode" waarde="register"/> Gebruikersnaam<br/> <invoerid = "gebruikersnaam" naam="gebruikersnaam" type="tekst" waarde="${formuser.userName }"/><label id = "userNameErr">${errors.loginname }</label><br/> Echte naam<br/> <invoernaam="trueName" type="text" waarde="${formuser.trueName }" />${errors.trueName }<br/> Wachtwoord<br/> <invoernaam="passWord" type="password" waarde="${formuser.passWord }"/>${errors.loginpass }<br/> Bevestig het wachtwoord<br/> <invoernaam="repassWord" type="wachtwoord" waarde="${reloginpass }" />${errors.reloginpass }<br/> Stad<br/> <invoernaam="stad" type="tekst" waarde="${formuser.city }"/>${errors.city }<br/> Woonadres<br/> <invoernaam="adres" type="tekst" waarde="${formuser.address }"/>${errors.address }<br/> Postcode<br/> <invoernaam="postcode" type="tekst" waarde="${formuser.postcode }" />${errors.postcode }<br/> ID-nummer<br/> <invoernaam="cardno" type="text" waarde="${formuser.cardno }"/>${errors.cartno }<br/> Soorten <br/>documenten <invoernaam="cardType" type="text" waarde="${formuser.cardType }"/>${errors.cardType }<br/> Contactnummer<br/> <invoernaam="tel" type="tekst" waarde="${formuser.tel }"/>${errors.tel }<br/> E-mail <br/> <invoernaam="e-mail" type="tekst" waarde="${formuser.email }"/>${errors.email }<br/> CAPTCHA <br/><img id= "vCode" src="<c:url value='/VerifyCodeServlet'/>">${errors.verifyCode } <label> <a href="javascript:_hyz()" > vervang één</a></label><br/> <invoernaam="verifieerCode" /><br/> <invoernaam="BtnRegister" type="verzenden" waarde="Register" /> <a href= "<c:url value='/index.jsp'/>" > keer terug naar de startpagina</a> </form> </body> </html> [/mw_shl_code]
[mw_shl_code=java, waar]/** * AJAX controleert of de gebruikersnaam geregistreerd is * @param vereiste * @param ademhaling * @return * @throws ServletException * @throws IOException */ publieke string verifyUserName(HttpServletRequest req, HttpServletResponse resp) werpt ServletException, IOException { Boolean b = onwaar; try { int i = userService.verifyUserName(req.getParameter("userName")); als (i==1) { b=waar; } } catch (SQLException e) { TODO Automatisch gegenereerd vangblok e.printStackTrace(); } Retourneert gegevens in JSON-formaat resp.getWriter().print("{\"bool\":\"qqq\"}"); resp.getWriter().print("{\"ifreg\":\""+b+"\"}"); resp.getWriter().print(b); System.out.println("{\"ifreg\":\""+b+"\"}"); return ""; }[/mw_shl_code]
|
-
1.png
(226.76 KB, Aantal downloads: 426)
-
2.png
(85.65 KB, Aantal downloads: 428)
-
3.png
(93.44 KB, Aantal downloads: 412)
-
4.png
(174.62 KB, Aantal downloads: 418)
-
5.png
(77.35 KB, Aantal downloads: 412)
-
6.png
(132.41 KB, Aantal downloads: 387)
-
7.png
(113.82 KB, Aantal downloads: 397)
Vorig:Struts2 aangepaste tijdomzetterVolgend:struts2 om de veelgebruikte objecten in de servlet te krijgen
|