The following snippet will cause mobile browsers to zoom in 320px of content. Useful for responsive design with fixed widths at the various breakpoints. Depends on JQuery. <script> if ($(window).width()
Category Archives: Code Snippet
Validating Canadian Postal Codes with the JQuery Validation Plugin
If you’re using the JQuery Validation Plugin, you can use the following code snippet to validate a Canadian postal code: jQuery.validator.addMethod(“cdnPostal”, function(postal, element) { return this.optional(element) || postal.match(/[a-zA-Z][0-9][a-zA-Z](-| |)[0-9][a-zA-Z][0-9]/); }, “Please specify a valid postal code.”); Then use the following rule: $(“#form”).validate({ rules: { postal_code: { required: true, cdnPostal: true } } });