Java Reference
In-Depth Information
Figure 6.6: Displaying error messages next to input fields
We can use the
error
class on the <span> tag to display the error text
in bold and red:
span.error {
font-weight: bold;
color: #880000;
padding: 8px;
}
Highlighting Errors
Stripes automatically adds
class=
"error" to labels and input fields that
are in error, as long as they are created with Stripes tags. We're already
using the <s:text> tag for the text fields; we need to use an <s:label>
tag to take advantage of this feature for labels. To associate a label to an
input field, place the name of the field in the
for=
attribute of <s:label>.
For example:
<tr>
<td><s:label for="contact.email">
Email:
</s:label></td>
<td>
<s:text name="contact.email" class="required"/>
</td>
<td><s:errors field="contact.email"/></td>
</tr>
<%-- same for other fields --%>
Search WWH ::
Custom Search