|
|
Diposting pada 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({ ketik:"DAPATKAN", cache:salah, asinkron:salah, url:"/bookShopping/UserServlet", data:{method:"verifyUserName",userName:value}, dataType:"json", success:function(result){ if(result.ifreg =="true"){ $("#userNameErr").text("Nama pengguna ini terdaftar!") ); } } }); }[/mw_shl_code]
[mw_shl_code=java,true] <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ awalan taglib="c" uri="http://java.sun.com/jsp/jstl/core"%> <!DOCTYPE HTML PUBLIC "-/W3C//DTD HTML 4.01 Transisi//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head>
<title>Halaman pendaftaran</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="kata kunci" content="kata kunci1,kata kunci2,kata kunci3"> <meta http-equiv="description" content="Ini adalah halaman saya"> <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"> fungsi _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"/> Nama<br/> pengguna <input id = "userName" name="userName" type="text" value="${formuser.userName }"/><label id = "userNameErr">${errors.loginname }</label><br/> Nama<br/> asli <input name="trueName" type="text" value="${formuser.trueName }" />${errors.trueName }<br/> Kata sandi<br/> <input name="passWord" type="password" value="${formuser.passWord }"/>${errors.loginpass }<br/> Konfirmasi kata sandi<br/> <input name="repassWord" type="password" value="${reloginpass }" />${errors.reloginpass }<br/> Kota<br/> <input name="city" type="text" value="${formuser.city }"/>${errors.city }<br/> Alamat<br/> tempat tinggal <input name="address" type="text" value="${formuser.address }"/>${errors.address }<br/> Kode pos<br/> <input name="postcode" type="text" value="${formuser.postcode }" />${errors.postcode }<br/> Nomor<br/> ID <input name="cardno" type="text" value="${formuser.cardno }"/>${errors.cartno }<br/> Jenis <br/>dokumen <input name="cardType" type="text" value="${formuser.cardType }"/>${errors.cardType }<br/> Nomor<br/> kontak <input name="tel" type="text" value="${formuser.tel }"/>${errors.tel }<br/> Email <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()" > mengganti satu</a></label><br/> <nama input = "verifyCode" /><br/> <input name="BtnRegister" type="submit" value="Register" /> <a href= "<c:url value='/index.jsp'/>" > kembali ke halaman beranda</a> </form> </body> </html> [/mw_shl_code]
[mw_shl_code=java,true]/** * AJAX memverifikasi apakah nama pengguna terdaftar * @param req * @param resp * @return * @throws ServletException * @throws IOException */ public String verifyUserName(HttpServletRequest req, HttpServletResponse resp) melemparkan ServletException, IOException { boolean b = salah; coba { int i = userService.verifyUserName(req.getParameter("userName")); jika (i==1) { b = benar; } } catch (SQLException e) { TODO Blok tangkapan yang dihasilkan secara otomatis e.printStackTrace(); } Mengembalikan data dalam format JSON resp.getWriter().print("{\"bool\":\"qqq\"}"); resp.getWriter().print("{\"ifreg\":\""+b+"\"}"); resp.getWriter().print(b); System.out.println("{\"ifreg\":\""+b+"\"}"); kembalikan ""; }[/mw_shl_code]
|
-
1.png
(226.76 KB, Jumlah unduhan: 426)
-
2.png
(85.65 KB, Jumlah unduhan: 428)
-
3.png
(93.44 KB, Jumlah unduhan: 412)
-
4.png
(174.62 KB, Jumlah unduhan: 418)
-
5.png
(77.35 KB, Jumlah unduhan: 412)
-
6.png
(132.41 KB, Jumlah unduhan: 387)
-
7.png
(113.82 KB, Jumlah unduhan: 397)
Mantan:Konverter Waktu Kustom Struts2Depan:struts2 untuk mendapatkan objek yang umum digunakan dalam servlet
|