diff --git a/example/web/index.html b/example/web/index.html index d4c802c..d99425f 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -39,19 +39,19 @@
-

+

-

+

-

+

-

+

-

+

@@ -64,20 +64,15 @@ /** * 注意:此demo比较简单,请结合实际项目修改 */ - var submitForm = document.getElementById('submitForm'); - var submitButton = document.getElementById('submitButton'); var validatorInstance = new WeValidator({ multiCheck: true, onMessage: function(data){ + console.log('onMessage'); console.log(data); for(var name in data){ - let ele = document.getElementById(name) - - if(ele){ - ele.innerHTML = data[name].msg - } + $('#' + name).html(data[name].msg) } }, rules: { @@ -117,27 +112,18 @@ } }); - submitButton.onclick = function(){ - var data = $(submitForm).serializeObject(); + // 提交 + $('#submitButton').on('click', function(){ + var data = $('#submitForm').serializeObject(); - console.log(data) - clearError() - if (!validatorInstance.checkData(data)) return; + console.log(data) - console.log('开始提交'); - - return false - } + $('.error-box').html('') - function clearError(){ - var eles = document.querySelectorAll('p') + if (!validatorInstance.checkData(data)) return; - eles = [].slice.call(eles) - - for(var i = 0; i < eles.length; i++){ - eles[i].innerHTML = '' - } - } + console.log('开始提交'); + }) \ No newline at end of file