こんばんは。
調べても分かりませんでしたので、質問をさせてください。
jspでこのようなソースを書いています。
入力のチェックをjavaの方で行っており、エラーメッセージが出た場合には、
該当のテキストボックスに色をつけたいのですが、jspのみでそのような方法は
ありますでしょうか。
よろしくお願いいたします。
<%@ page language="java" contentType="text/html; charset=EUC_JP" pageEncoding="Windows-31J"%> <%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld"%> <%@ taglib prefix="fn" uri="/WEB-INF/tld/fn.tld"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC_JP"> <c:import url="./head.jsp" /> <link rel="stylesheet" type="text/css" href="../css/customerDetail.css"> <link rel="stylesheet" type="text/css" href="../css/error.css"> <script type="text/javascript" src="../js/dialog.js" charset="UTF-8"> </script> <title>編集画面</title> <script type="text/javascript"> function touroku() { // 「OK」時の処理 + 確認ダイアログの表示 if (window.confirm('本当に登録してよろしいですか?')) { location.href = "/Kadai/page/customerDetail.jsp"; return true; } //キャンセルしたら元の画面に戻る return false; } function kousin() { var msg; if (document.form1.deleteFlag.checked) { msg = "削除"; } else { msg = "更新"; } // 「OK」時の処理 + 確認ダイアログの表示 if (window.confirm('本当に' + msg + 'してよろしいですか?')) { location.href = "/Kadai/page/customerList.jsp"; return true; } //キャンセルしたら元の画面に戻る return false; } </script> </head> <body> <form action="./CustomerDetail" method="post" name="form1"> <table> <tr> <th>顧客ID</th> <td><c:choose> <c:when test="${processType == 'insert'}"> <input type="text" name="id" size="12" value="${id}"> </c:when> <c:otherwise> <c:out value="${id}" /> <input type="hidden" name="id" value="${id}"> </c:otherwise> </c:choose></td> </tr> <tr> <th>顧客漢字名</th> <td><input type="text" name="name" size="20" value="${name}"></td> </tr> <tr> <th>顧客カナ名</th> <td><input type="text" name="kana" size="20" value="${kana}"></td> </tr> <tr> <th>性別</th> <td><select name="gender"> <c:forEach var="generalDto" items="${genderList}" varStatus="status"> <c:choose> <c:when test="${generalDto.detailCode == gender}"> <option value="${generalDto.detailCode}" selected><c:out value="${generalDto.contents1}" /></option> </c:when> <c:otherwise> <option value="${generalDto.detailCode}"><c:out value="${generalDto.contents1}" /></option> </c:otherwise> </c:choose> </c:forEach> </select></td> </tr> <tr> <th>身長</th> <td><input type="text" name="height" size="12" value="${height}">cm</td> </tr> <tr> <th>体重</th> <td><input type="text" name="weight" size="12" value="${weight}">kg</td> </tr> <tr> <th>生年月日</th> <td><input type="text" name="birthday" size="12" value="${birthday}">(yyyy/MM/ddで入力してください)</td> </tr> <tr> <th>郵便番号</th> <td><input type="text" name="zipCode" size="14" value="${zipCode}">(ハイフン無しで入力してください)</td> </tr> <tr> <th>住所</th> <td><input type="text" name="address" size="40" value="${address}"></td> </tr> <tr> <th>電話番号</th> <td><input type="text" name="phone" size="14" value="${phone}">(ハイフンありで入力してください)</td> </tr> <c:choose> <c:when test="${processType == 'insert'}"> </c:when> <c:otherwise> <tr> <th>削除</th> <td><input type="checkbox" name="deleteFlag" size="12" value="${1}"></td> </tr> </c:otherwise> </c:choose> </table> <c:choose> <c:when test="${processType == 'insert'}"> <input type="text" name="processType" value="insert" style="display: none"> <input type="submit" value="OK" onClick="return touroku()" /> </c:when> <c:otherwise> <input type="text" name="processType" value="update" style="display: none"> <input type="submit" value="OK" onClick="return kousin()" /> </c:otherwise> </c:choose> <input type="submit" value="一覧へ" name="backList" /> </form> </body> </html>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/06/29 13:54
2015/06/29 14:11