Created
September 15, 2016 21:33
-
-
Save jessegilbride/19d4d18db9f06eb35bbe1d57129aa43e to your computer and use it in GitHub Desktop.
Revisions
-
jessegilbride created this gist
Sep 15, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ $("form").validate({ rules: { Zip: {zipCodeValidation: true} // hook in custom zip code validation } }); $.validator.addMethod("zipCodeValidation", function() { var zipCode = $('input#zip').val(); return (/(^\d{5}$)|(^\d{5}-\d{4}$)/).test(zipCode); // returns boolean }, "Please enter a valid US zip code (use a hyphen if 9 digits)."); $("#submitButton").on("click", function(e) { e.preventDefault(); var form = $("#myForm"); form.validate(); // "validate" method is required for jquery.validate.js if (infoRequestForm.valid()) { // console.log("the form is valid."); // ------------------------------------------------------------ // // CODE TO SUBMIT FORM GOES HERE. // // ------------------------------------------------------------ $(".formContainer").hide(); $(".thankYouMessage").show(); } });