clay1 Posted January 6, 2010 Share Posted January 6, 2010 When I click submit nothing happens. I have the problem narrowed down to the zipcode validation. jQuery.validator.addMethod("phoneUS", function(phone_number, element) { phone_number = phone_number.replace(/\s+/g, ""); return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/); }, "Please specify a valid phone number"); jQuery.validator.addMethod("zipcode", function(zip) { // matches US ZIP code // allow either five digits or nine digits with an optional '-' between zip = zip.replace(/^\s+/, ""); zip = zip.replace(/\s+$/, ""); if(zip.length == 0) { return true; } if(zip.match(/^\d{5}([- ]?\d{4})?$/)) { return true; } return false; }, "Please specify a valid US ZIP code(5 digits or xxxxx-xxxx format)"); If I don't enter a zip it tells me to but when I do the form won't post. If I remove that code the form will post but obviously my zipcode field won't be validated. I've tried a few different versions of validating the zip but everytime I try the form won't post. Link to comment https://forums.phpfreaks.com/topic/187375-jquery-validation-quandry/ Share on other sites More sharing options...
clay1 Posted January 6, 2010 Author Share Posted January 6, 2010 Anyone? Link to comment https://forums.phpfreaks.com/topic/187375-jquery-validation-quandry/#findComment-990022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.