我遇到了formatter.js和验证jquery插件的问题。
<div class="formClear">
<label for="text-basic">
Phone<em> *</em></label>
<input type="tel" name="Phone" id="Phone" class="required" />
</div>
当我将以下格式化程序应用于特定字段,然后使用jquery验证插件将其设置为必填字段时,jquery插件不再将其作为必填字段强制执行。
if (document.getElementById('Phone') != null) {
new Formatter(document.getElementById('Phone'), {
'pattern': '({{999}}) {{999}}-{{9999}}',
'persistent': true
});
}
如果我把这段代码注释掉,字段的必填项就会强制执行。。。但当两者都到位时,“电话”字段的验证不会发生。就好像这两者并不是为了兼容而设计的。
具体来说,在调用checkForm()之后,errorMap对象具有除Phone之外的所有验证失败。格式化程序是否删除了jquery验证插件所依赖的一些事件处理程序,因此,我需要添加额外的代码?如有任何见解/代码示例,将不胜感激。