1
我使用的是knockout.js validation plugin,它對我正在使用的表單進行驗證非常有效,但是它似乎沒有跟蹤錯誤的數量。當我提交表格時,如果它檢測到任何錯誤,它不應該提交,但它正在提交。knockout.js驗證錯誤計數未設置
function EntryViewModel(fullName, addressLine1, addressLine2, city, state, ZIP, email) {
//viewmodel code here
//the validation messages are being set on my form so i figure listing all of the rules is not necessary
self.submitOrder = function(){
alert(EntryViewModel.errors().length); //displays 0
if (EntryViewModel.errors().length == 0) {
//submit
}
else{
alert('Please fix errors before submitting');
}
}
}
EntryViewModel.errors = ko.validation.group(EntryViewModel); //I also tried putting this in my viewmodel and it didn't do anything
我可以處理這個完全錯誤的,我只是立足它關閉的是從GitHub的友情鏈接的項目this fiddle
就是這樣,謝謝! – user1443519