title: How to validate all the form fields in Struts 2
body: <p>I have created one login page with the following fields,now how can i validate these fields before submitting it for authentication? Please guide me,I am new to struts2. Is struts2 provides any otherway of validating form fields?</p>
  
  <p>Which one is the best approach? can i able to use javascript to validate struts2 form fields?</p>
  
  <p>please guide me.Thanks in advance</p>
  
  <p>My action class name is LoginAction.java</p>
  
  <p>and my login.jsp is</p>
  
  <pre><code>&lt;s:form action=""&gt;
              &lt;s:textfield label="Username" key="username"&gt;&lt;/s:textfield&gt;&lt;br/&gt;
              &lt;s:password label="Password" key="password"&gt;&lt;/s:password&gt;&lt;br/&gt;
              &lt;s:textarea label="Address" key="address"&gt;&lt;/s:textarea&gt;
              &lt;s:radio list="{'Male','Female'}" label="Gender" key="gender"&gt;&lt;/s:radio&gt;
              &lt;s:file key="file"&gt;&lt;/s:file&gt;
              &lt;s:select list="{'Select a value','India','Australia','England','Srilanka','Japan','Other'}" label="Country"    key="country"&gt;&lt;/s:select&gt;    
              &lt;s:submit label="Add Information"&gt;&lt;/s:submit&gt;
              &lt;/s:form&gt;  
  </code></pre>
  
  <p>I have created one login page with the following fields,now how can i validate these fields before submitting it for authentication? Please guide me,I am new to struts2. Is struts2 provides any otherway of validating form fields?</p>
  
  <p>which one is the best approach? can i able to use javascript to validate struts2 form fields?</p>
  
  <p>please guide me.Thanks in advance </p>
  
  <pre><code>My action class name is LoginAction.java     
  </code></pre>