Skip to content

Instantly share code, notes, and snippets.

@NHZEX
Created March 27, 2019 11:20
Show Gist options
  • Select an option

  • Save NHZEX/e91eb01bd7f37a7c3590bb185c056111 to your computer and use it in GitHub Desktop.

Select an option

Save NHZEX/e91eb01bd7f37a7c3590bb185c056111 to your computer and use it in GitHub Desktop.
表单提交处理
let submit = function(target) {
// 表单校验
that.gFormItem = that.findInputs(form);
if (that.isAllpass(that.gFormItem)) {
// 提前定位,防止提示被遮挡
that.focus(target);
that.passCall.call(that, form, target);
}
};
// 一级截取
$form.find('[type=submit]').bind('click', function (event) {
// 阻止默认事件
event.preventDefault();
// 表单校验
submit(event.target);
return false;
});
// 二级截取
$form.bind('submit', function (event) {
// 阻止默认事件
event.preventDefault();
// 表单校验
submit($form.find('button[type=submit], input[type=submit]').first() || event.target);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment