Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts2 Form Theme Simple: Error Message on the wrong position
    primarykey
    data
    text
    <p>I want my error message to the right side of my field. However when the password field has an error, the error message of the password is on the right side of the userName field. Why does it behave that way? base on the w3schools my format is correct. The error message password not correct should be on the right side of the password field.</p> <p>This is the pattern I am following inside my form.</p> <pre><code>&lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt;UserNAme&lt;/td&gt; &lt;td&gt;UserName Error message&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Password&lt;/td&gt; &lt;td&gt;Password Error Message&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This is my Struts2 Code.</p> <pre><code> &lt;!--Struts2 log-in--&gt; &lt;s:form method="POST" action="login" theme="simple" &gt; &lt;table border="1" &gt; &lt;tr&gt; &lt;td&gt; UserName:&lt;s:textfield label="UserName" key="userName" maxLength="20"/&gt; &lt;/td&gt; &lt;td class="errorMessage"&gt; &lt;s:property value="fieldErrors.get('userName').get(0)" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; PassWord:&lt;s:password label="Password" key="password" maxLength="20"/&gt; &lt;/td&gt; &lt;td class="errorMessage"&gt; &lt;s:property value="fieldErrors.get('password').get(0)" /&gt; &lt;td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;s:submit value="Login" align="center"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/s:form&gt; This is the html result of the struts. &lt;!--Struts2 log-in--&gt; &lt;form id="login" name="login" action="/springtest/login.action" method="POST"&gt; &lt;table border="1" &gt; &lt;tr&gt; &lt;td&gt; UserName:&lt;input type="text" name="userName" maxlength="20" value="tok" id="login_userName"/&gt; &lt;/td&gt; &lt;td class="errorMessage"&gt; Username don't exist. &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; PassWord:&lt;input type="password" name="password" maxlength="20" id="login_password"/&gt; &lt;/td&gt; &lt;td class="errorMessage"&gt; &lt;td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="submit" id="login_0" value="Login"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    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