teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

情報の追加

2020/02/23 00:59

投稿

encho
encho

スコア182

title CHANGED
File without changes
body CHANGED
@@ -84,6 +84,57 @@
84
84
  }
85
85
 
86
86
  ```
87
+ ```html
88
+ <!DOCTYPE html>
89
+ <html xmlns:th="http://www.thymeleaf.org">
90
+ <head>
91
+ <meta charset="UTF-8" />
92
+ <title>ユーザー登録</title>
93
+ <style>
94
+ .err {
95
+ color: red;
96
+ }
97
+ </style>
98
+ </head>
99
+ <body>
100
+ <div>
101
+ <h1>ユーザー登録</h1>
102
+ <table>
103
+ <form th:action="@{/account}" action="/account" th:object="${accountForm}" method="post">
104
+ <tr><td><label for="userName">ユーザ名:</label></td>
105
+ <td><input type="text" name="userName" th:field="*{userName}" th:errorclass="err"/>
106
+ <div th:if="${#fields.hasErrors('userName')}" th:errors="*{userName}" th:errorclass="err">
107
+ </div>
108
+ </td>
109
+ </tr>
110
+ <tr>
111
+ <td><label for="mailAddress">メールアドレス</label></td>
112
+ <td><input type="text" name="mailAddress" th:field="*{mailAddress}" th:errorclass="err"/>
113
+ <div th:if="${#fields.hasErrors('mailAddress')}" th:errors="*{mailAddress}" th:errorclass="err">
114
+ </div>
115
+ </td>
116
+ </tr>
117
+ <tr>
118
+ <td><label for="password">パスワード</label></td>
119
+ <td><input type="password" name="password" th:field="*{password}" th:errorclass="err"/>
120
+ <div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" th:errorclass="err">
121
+ </div>
122
+ </td>
123
+ </tr>
124
+ <tr>
125
+ <td><label for="confirmPassword">パスワード(確認)</label></td>
126
+ <td><input type="password" name="confirmPassword" th:field="*{confirmPassword}" th:errorclass="err"/>
127
+ <div th:if="${#fields.hasErrors('confirmPassword')}" th:errors="*{confirmPassword}" th:errorclass="err">
128
+ </div>
129
+ </td>
130
+ </tr>
131
+ <tr><td></td><td><input type="submit" value="新規登録" /></td></tr>
132
+ </form>
133
+ </table>
134
+ </div>
135
+ </body>
136
+ </html>
137
+ ```
87
138
 
88
139
  以上のようにそれぞれのバリデーション に対するメッセージをグループ化して
89
140
  Default,group1,group2の順にバリデーション を適用させたいのですが