Created
April 29, 2015 19:34
-
-
Save johnbocook/92fdfdd0a7079dae5c13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
lp.jQuery(function($) { | |
var ruleID = 'zipCode' | |
var field = 'zip_code'; | |
var message = 'Please enter a valid ZIP code'; | |
var rules = module.lp.form.data.validationRules[field]; | |
$.validator.addMethod(ruleID, function(value, field) { | |
var valid = /^\d{5}([\-]?\d{4})?$/.test(value); | |
return valid || (!rules.required && !value); | |
}, message); | |
rules[ruleID] = true; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment