Created
March 27, 2019 11:20
-
-
Save NHZEX/e91eb01bd7f37a7c3590bb185c056111 to your computer and use it in GitHub Desktop.
表单提交处理
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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