1.數字大小驗證規則,很經常使用,不能超過數據庫的字符限制吧html
between: { min: 2, max: 100, message: 'The number of floors must be between 2 and 100' }
2.當你輸出完成後調用的方法,value是你輸入的值,你對它進行計算或者驗證,以後返回true表明驗證成功,false失敗表明驗證失敗。你也能夠利用它去後臺發送ajax請求來驗證,只是注意性能,由於請求有點多,需求不大能夠設置前端緩存前端
callback: { message: 'Wrong answer', callback: function (value, validator, $field) { // Determine the numbers which are generated in captchaOperation var items = $('#captchaOperation').html().split(' '), sum = parseInt(items[0]) + parseInt(items[2]); return value == sum; } }
3.和 field中填寫的表單 內容不能同樣, 好比不讓密碼和用戶名同樣ajax
different: { field: 'username', message: 'The password cannot be the same as username' }
4.和 regexp你們都懂的,不解釋=!=數據庫
regexp: { regexp: /^[a-z\s]+$/i, message: 'The full name can consist of alphabetical characters and spaces only' }
5.非空,不解釋=!=bootstrap
notEmpty: { message: 'The full name is required' }
6.字符串長度驗證規則緩存
stringLength: { max: 50, message: 'The full name must be less than 50 characters' }
7.字符串大小寫驗證規則less
stringCase: { message: 'The card holder must be in uppercase', 'case': 'upper' // Can be lower default or upper }
8.整數驗證性能
integer: { message: 'The value is not an integer' }
9.遠程請求ui
remote: { message: 'The username is not available', url: '/path/to/backend/' }
10.驗證文件url
file: { extension: 'jpeg,png', type: 'image/jpeg,image/png', maxSize: 2048 * 1024, message: 'The selected file is not valid' }
詳情請參考http://bootstrapvalidator.vot...裏面有大量使用案例,後續我寫的多了也會補充,如今只是暫時作一個記錄,之後用一個在這裏記一個