2
自定义表单验证-Magento
我正在尝试使用jQuery在Magento中实现一些自定义表单验证,但是我不确定我是否具有正确的方法。 基本上,我需要验证以下内容: 仅数字字段需要具有.00才能验证1到1.00 字母必须大写 号码不能大于9.99 字段中没有空格 我正在考虑使用jQuery,并着手编写一些东西来验证表单: <script> jQuery(document).ready(function() { jQuery.validator.addMethod("integer", function(value, element) { return this.optional(element) || /^-?\d+$/.test(value); }, "A positive or negative non-decimal number please"); function(field, length) { if (!numericRegex.test(length)) { return false; } return (field.value.length <= parseInt(length, 4)); }, } </script> 问题是我找不到其他验证字段的功能,请提供一些帮助。