Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC - How to set parent div's class when there are validation errors?
    primarykey
    data
    text
    <p>Are there any ways to bind arbitrary element's css class to model bind state?</p> <pre><code>&lt;form:form method="post" commandName="authForm" action="authenticate"&gt; &lt;div id="login-error" class="control-group"&gt; &lt;label&gt;Login&lt;/label&gt; &lt;form:input path="name" /&gt; &lt;span class="help-inline"&gt;&lt;form:errors path="name" /&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="control-group"&gt; &lt;label&gt;Password&lt;/label&gt; &lt;form:input path="password" /&gt; &lt;span class="help-inline"&gt;&lt;form:errors path="password" /&gt;&lt;/span&gt; &lt;/div&gt; &lt;input type="submit" /&gt; &lt;/form:form&gt; </code></pre> <p>In this piece of code I need to manage <code>login-error</code>'s class to <code>control-group</code> when there are no errors and <code>control-group error</code> when there are (the same idea for second <code>control-group</code>).</p> <p>What's the common solution here?</p> <p><strong>Update</strong></p> <p>Here's what I need when there's no bind error:</p> <pre><code>&lt;div class="control-group"&gt; &lt;!-- !!!!!!!!!!!! --&gt; &lt;label&gt;Login&lt;/label&gt; &lt;form:input path="name" /&gt; &lt;span class="help-inline"&gt;&lt;form:errors path="name" /&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>Here's what I need when there is a bind error:</p> <pre><code>&lt;div class="control-group error"&gt; &lt;!-- !!!!!!!!!!!! --&gt; &lt;label&gt;Login&lt;/label&gt; &lt;form:input path="name" /&gt; &lt;span class="help-inline"&gt;&lt;form:errors path="name" /&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>Looking for solution.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload