差的資。料說是用ajax做?可是我不會ajax,ajax實(shí)在不會寫了。。。html部分<p> <label>編號:</label> <input name="custom_number" type="text" size="30" id="custom_number" value="<%=item.getCustom_number() == null ? "" : item.getCustom_number()%>" maxlength="50" /></p>javascript部分<script>$('#custom_number').change(function(){ $.ajax({ url: '<%=basePath%>admin/custom/repeat.html?custom_number=' + $('#custom_number').val(), dataType: 'post', });</script>后臺數(shù)據(jù)庫代碼 @RequestMapping(value = "/repeat") public void repeat(HttpServletRequest request, HttpServletResponse response, String custom_number) throws SQLException, IOException{ ConnectionSource connectionSource = DBUtil.getConnectionSource(); Dao<zqbp_custom, String> dao = DaoManager.createDao(connectionSource, zqbp_custom.class); QueryBuilder<zqbp_custom, String> where = dao.queryBuilder(); List<zqbp_custom> list = where.where().eq("custom_number", custom_number).query(); if(list.size()==0){ }else { response.getWriter().write("編號重復(fù),請重新輸入"); response.getWriter().close(); } }
3 回答

HUH函數(shù)
TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超4個(gè)贊
1.你后臺肯定得檢索數(shù)據(jù)庫。
2.前臺直接判斷就得發(fā)送請求。
3.你不想跳轉(zhuǎn),那只能是ajax發(fā)送請求。
你上網(wǎng)google一個(gè)例子,我就不當(dāng)搬運(yùn)工了,ajax就是個(gè)js發(fā)送http請求。
另外題主你說java?還是javascript?

元芳怎么了
TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超7個(gè)贊
jquery validation找個(gè)這個(gè)來用
當(dāng)然自己做也沒什么難的 最多做的丑一點(diǎn)
添加回答
舉報(bào)
0/150
提交
取消