Webshims 实现了 HTML5 指定的表单验证 API。您可以阅读以下错误报告和我的回答:https ://github.com/aFarkas/webshim/issues/103#issuecomment-4298458
这是您的问题的简短“解决方法”:
//configure webshims to use customized bubbles
$.webshims.setOptions('forms', {
replaceValidationUI: true
});
//start polyfilling forms feature
$.webshims.polyfill('forms');
$(function(){
$('myLink').click(function(e) {
if($('myForm').checkValidity()){
$('myForm').submit();
}
});
});
但要明确这一点,最好的方法是使用提交按钮。要设置提交按钮的样式,这是一个简单的按钮重置,它应该可以在 x 浏览器中使用:
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
input.btn-reset,
button.btn-reset {
overflow: visible;
display: inline-block;
border: none;
padding: 0;
background: transparent;
-webkit-appearance: none;
color: #000;
font-family: arial,helvetica,sans-serif;
cursor: pointer;
}