我使用webshim檢查兩個文本輸入中是否有文本,並認爲自定義有效性聽起來正確。 http://afarkas.github.io/webshim/demos/demos/webforms/4-webforms-custom-validity.html運行webshim「addCustomValidityRule」
有一個名爲addCustomValidityRule
方法,看起來像這樣:
$.webshims.addCustomValidityRule('testname', function (elem, value) {
if (value && $(elem).hasClass('test-class') && value != 'foo bar baz') {
return true; //means yes, it's not valid
} else {
return false; //no, it is valid
}
}, 'you have to enter foo bar baz');
但我無法找到任何方式來觸發它。我如何觸發或運行「提交點擊」?