表单校验 - + //jsdirectives: { numberOnly: { bind: function(el) { el.handler = function() { var formatVal = /^\+?[1-9][0-9]*$/; var val = el.value; if(!formatVal.test(val)){ var reg = new RegExp(val,'g'); el.value = val.replace(reg, 1);
//js directives: { numberOnly: { bind: function(el) { el.handler = function() { var formatVal = /^\+?[1-9][0-9]*$/; var val = el.value; if(!formatVal.test(val)){ var reg = new RegExp(val,'g'); el.value = val.replace(reg, 1); } } el.addEventListener('input', el.handler) }, unbind: function(el) { el.removeEventListener('input', el.handler) } } }, //原生