Reputation: 664
I would like to style my forms in case of errors a bit more.
Standard-usage is to print the error with help of <f:errors path="name" cssClass="error" />
But I want to mark the corresponding text fields as well - maybe by adding an additional style.
Can this be done in an easy way?
Thanks in advance and cheers
Martin
Upvotes: 1
Views: 5204
Reputation: 1370
So late, but it can be useful for someone else.
A very easy way now, using the cssErrorClass, i.e.:
<form:input path="id" class="form-control height30px" cssErrorClass="form-control height30px error"/>
Upvotes: 5
Reputation: 86
One easy way I can think of is:
<c:set var="inputCls" value="niceInputCls" scope="page" />
<form:errors path="name" cssClass="error">
<c:set var="inputCls" value="errorInputCls" scope="page" />
</form:errors>
And in your input tag:
<form:input path="name" cssClass="${inputCls}" />
You can define your normal input and error input style classes.
Upvotes: 3
Reputation: 22948
You can do that as well for the input fields here is that example :
http://www.mkyong.com/spring-mvc/spring-mvc-form-errors-tag-example/
Upvotes: 0