I am trying to implement some custom form validation in Magento using jQuery but I am not sure if I have the correct method.
Basically, I need to validate the following:
Only number fields need to have .00 to validate 1 to 1.00
Letters need to be uppercase
Cannot have number greater than 9.99
No spaces in the fiels
I am thinking to use jQuery and have set about writing something up to validate the form:
<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>
The problem is I cannot find the functions for the other validation fields and could do with some assistance please???