2014-12-24 71 views
0

所以我有這種形式,它需要一個驗證,我使用引導,但現在我試圖插入值到我的數據庫使用休眠,但它不會讓我因爲它需要「必需的自動對焦」或「需要」一個等號,我沒有看到任何關於bootstrap的文檔如何驗證我的表單。我現在需要使用javascript驗證我的表單嗎?我希望有人能幫助我在這裏是我的代碼使用bootstrap驗證表單使用spring框架休眠

<c:url var="actionUrl" value="save" /> 
    <form:form id="registerForm" commandName="users" method="post" action="${actionUrl }" class="form-horizontal" > 
     <fieldset> 
     <div class="form-group"> 
      <label class="col-lg-2 control-label" for="email">Email</label> 
      <div class="col-lg-10"> 
      <form:input path="email" class="form-control" placeholder="Email Address" type="email" required autofocus /> 
      </div> 
     </div> 

     <div class="form-group"> 
      <label class="col-lg-2 control-label" for="username">Username</label> 
      <div class="col-lg-10"> 
      <form:input path="username" class="form-control" placeholder="Username" type="username" required /> 
      </div> 
     </div> 

     <div class="form-group"> 
      <label class="col-lg-2 control-label" for="password">Password</label> 
      <div class="col-lg-10"> 
      <form:input path="password" class="form-control" placeholder="Password" type="password" required /> 
      </div> 
     </div> 

     <div class="form-group"> 
      <label class="col-lg-2 control-label" for="location">Location</label> 
      <div class="col-lg-10"> 
       <form:select path="location" class="form-control" type="location" > 
       <option>France</option> 
       <option>Amsterdam</option> 
       <option>Philippines</option> 
       <option>Others</option> 
      </form:select> 

      <form:input path="userId" type="hidden" /> 
      </div> 
     </div> 

     <div class="modal-footer"> 
      <button class="btn btn-primary" type="submit" id="register">Register</button> 
      <button class="btn btn-default" data-dismiss="modal" type="button">Cancel</button> 
     </div><!-- end modal-footer --> 
     </fieldset> 
    </form:form> 
+0

您已經添加驗證來引導模式窗口?如果是這樣,提交後你如何避免模式窗口關閉? – olgacosta

回答

1

只是添加了所有輸入字段 <form:errors path="username" /> 等..它爲我工作