|
|
Pubblicato su 24/12/2014 02:28:19
|
|
|
|

[mw_shl_code=javascript,true]$(function(){ $("#userName").blur(function() { var value = $("#userName").val(); verifyUserName(valore); }); $("#userName").focus(function() { $("#userNameErr").testo(""); }); });
funzione verifyUserName(userName){ var value = $("#userName").val(); $.ajax({ tipo:"GET", cache:falso, async:false, url:"/bookShopping/UserServlet", data:{metodo:"verificareNomeUtente",NomeUtente:valore}, dataType:"json", successo:funzione(risultato){ if(result.ifreg =="true"){ $("#userNameErr").text ("Questo username è registrato!") ); } } }); }[/mw_shl_code]
[mw_shl_code=java,vero] <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitorio//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>
<title>Pagina di registrazione</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="parole chiave" content="parola chiave1,parola2,parola3"> <meta http-equiv="description" content="Questa è la mia pagina"> <script type="testo/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="testo/javascript"> funzione _hyz() { $("#vCode").attr("src", '<c:url value='/VerifyCodeServlet?'/>' + new Date().getTime());
} </script> </head>
<body> <form action="/bookShopping/UserServlet"> <input type="hidden" name="method" value="register"/> Nome<br/> utente <input id = "userName" nome="userName" tipo="testo" valore="${formuser.userName }"/><etichetta id = "userNameErr">${errors.loginname }</label><br/> Vero nome<br/> <nome di input="trueName" type="text" value="${formuser.trueName }" />${errors.trueName }<br/> Password<br/> <input name="passWord" type="password" value="${formuser.passWord }"/>${errors.loginpass }<br/> Conferma la password<br/> <input name="repassWord" type="password" value="${reloginpass }" />${errors.reloginpass }<br/> Città<br/> <input name="city" type="text" value="${formuser.city }"/>${errors.city }<br/> Indirizzo<br/> residenziale <nome input="address" tipo="testo" valore="${formuser.address }"/>${errors.address }<br/> CAP<br/> <input name="postcode" type="text" value="${formuser.postcode }" />${errors.postcode }<br/> Numero<br/> ID <input name="cardno" type="text" value="${formuser.cardno }"/>${errors.cartno }<br/> Tipi di <br/>documenti <input name="cardType" type="text" value="${formuser.cardType }"/>${errors.cardType }<br/> Numero<br/> di contatto <input name="tel" type="text" value="${formuser.tel }"/>${errors.tel }<br/> E-mail <br/> <input name="email" type="text" value="${formuser.email }"/>${errors.email }<br/> CAPTCHA <br/><img id= "vCode" src="<c:url value='/VerifyCodeServlet'/>">${errors.verifyCode } <label> <a href="javascript:_hyz()" > sostituirne uno</a></label><br/> <input name="verifyCode" /><br/> <nome input="BtnRegister" tipo="invia" valore="Register" /> <a href= "<c:url value='/index.jsp'/>" > torna alla home</a> page </form> </body> </html> [/mw_shl_code]
[mw_shl_code=java,true]/** * AJAX verifica se il nome utente è registrato * @param richiesta * @param respiro * @return * @throws ServletException * @throws IOException */ Public String verifyUserName (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Booleano B = falso; try { int i = userService.verifyUserName(req.getParameter("userName")); if (i==1) { b=vero; } } catch (SQLException e) { TODO blocco di presa auto-generato e.printStackTrace(); } Dati di ritorno in formato JSON resp.getWriter().print("{\"bool\":\"qqq\"}"); resp.getWriter().print("{\"ifreg\":\""+b+"\"}"); resp.getWriter().print(b); System.out.println("{\"ifreg\":\""+b+"\"}"); ritorno ""; }[/mw_shl_code]
|
-
1.png
(226.76 KB, Numero di download: 426)
-
2.png
(85.65 KB, Numero di download: 428)
-
3.png
(93.44 KB, Numero di download: 412)
-
4.png
(174.62 KB, Numero di download: 418)
-
5.png
(77.35 KB, Numero di download: 412)
-
6.png
(132.41 KB, Numero di download: 387)
-
7.png
(113.82 KB, Numero di download: 397)
Precedente:Convertitore di tempo personalizzato struts2Prossimo:struts2 per ottenere gli oggetti comunemente usati nel servlet
|