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:
Download email_09/web/css/style.css
span.error {
font-weight: bold;
color: #880000;
padding: 8px;
}
This will display error messages as in Figure 6.6 .
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:
Download email_10/web/WEB-INF/jsp/contact_form.jsp
<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