我的表單有兩個提交按鈕,一個提交主窗體,另一個提交使用ajax發送數據。無法弄清楚如何告訴bootstrap驗證程序,在這種情況下我們使用不同的提交按鈕。是的,在提交即時通訊使用preventDefault();使用bootstarp驗證器的目標特定提交按鈕
$("#submitformat").click(function(event) {
$('#formid').bootstrapValidator({ // this id is correct
message: 'This value is not valid',
fields: {
alias: {
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and cannot be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
},
regexp: {
regexp: /^[a-zA-Z0-9_]+$/,
message: 'The username can only consist of alphabetical, number and underscore'
}
}
},
}
});
HTML按鈕:
<button type="submit" id="submitformat" class="btn btn-primary">Submit</button>