title: Spring MVC Front End Validations
body: <p>I wanted to validate user inputs in my jsp which were binded to Springformdata objects using <code>&lt;spring:bind&gt;</code> without hitting the controller.</p>
  
  <p>Is there any other way I can achive this in spring MVC without using javascrpit.</p>
  
  <p>See below code</p>
  
  <pre><code>&lt;tr&gt;&lt;td&gt;
                          &lt;spring:bind path="applyDmlFormData.file"&gt;
                              Select DML File : &lt;input type="file" name="file"/&gt; 
                          &lt;/spring:bind&gt;
                      &lt;/td&gt;&lt;/tr&gt;
  </code></pre>
  
  <p>Here I am asking user to browse/select the input file and then attaching that to applyDmlFormData objects' file property.</p>
  
  <p>If user don't selects any file and submits the form I wanted to validate that in the forntend itself without hitting the controller and display a error message saying file must me choosen. Basically I wanted to achieve the same functionality which is available in struts validation framework.</p>
  
  <p>One more thing to add is I dont want to use validator which will be invoked by controller</p>
  
  <pre><code>@RequestMapping(value="/applyDml.htm", method = RequestMethod.POST)
      public String process(@ModelAttribute("applyDmlFormData") ApplyDmlFormData applyDmlFormData, BindingResult result, SessionStatus status, HttpServletRequest request)
      {
          String mav = applyDmls;
          validator.validate(applyDmlFormData, result);
  
          if(!result.hasErrors())
          { //Business logic goes here
          }
      }
  </code></pre>
  
  <p>In the above code I am validating user inputs using validator.validate I dont want to do that.</p>