2016-04-07 153 views
0

我有一個很奇怪的問題:登錄我的web應用程序後,我被一個servlet重定向到我的儀表板。在儀表板有一種使用自舉Jsp html表單驗證不起作用

<li><a href="DashboardUser.jsp">Add User</a></li> 

DashboardUser.jsp是一個形式來創建新的用戶包裹在一個導航欄的鏈接。所有表單輸入都標有required。所以如果我嘗試提交表單而不填寫它的工作原理(不驗證)。該servlet獲得所有屬性與無效和轉發拋出異常DashboardUser一個錯誤消息

request.setAttribute("errorMessage","error etc."); 
request.getRequestDispatcher("DashboardUser.jsp").forward(request, response); 

轉發回表單驗證開始工作後!以前有什麼問題?順便說一下:我需要一個表單驗證插件,它可以與bootstrap協同工作。我嘗試了一些插件,但都沒有工作。

謝謝!

回答

0

你檢查了你的console for any errors嗎?在檢查client-side validation錯誤時,請不要提交頁面。發現錯誤,如果你發現任何東西。

既然你已經問過了,我的建議是嘗試支持bootstrap的Form Validation

爲了驗證適用於特定的領域:

$(form).formValidation({ 
    fields: { 
    fieldName: { 
     // Replace validatorName with the name of validator 
     // validatorOptions will be passed as third parameter of the 
     // validate(validator, $field, options) method 
     validatorName: validatorOptions 
    } 
    } 
}); 

你可以在這裏找到example