How do I validate a zip code in a form?


I need to validate the length and only digits in a zip code field.

As far as I can see it’s only possible to validate email and phone as default in Unbounce?

<script type="text/javascript"\>  
var d =;  
/\* Change the main error message title \*/  
jQuery(document).ready(function() {  
"Please correct the following errors:"  
/\* Change the individual error messages \*/  
d.validationMessages = {  
"customer_full_name": {  
required: "Type your name"
"customer_full_address": {  
required: "Type your address"
"customer_email": {  
required: "Type your email",  
email: "Please type a valid email"
"customer_zipcode": {  
required: "Type your zip code",
"customer_phone": {  
required: "Type your phone number",
phone: "Type a valid phone number"

Found a solution:

lp.jQuery(function($) {
  var ruleID = 'zipcode';
  var field = 'customer_zipcode';
  var message = 'Indtast kun postnummeret';
  var rules =[field];
  $.validator.addMethod(ruleID, function(value, field) {
        var valid = /^(?:[0-9]{4})?$/.test(value);
        return valid || (!rules.required && !value);
        }, message);
rules[ruleID] = true;
1 Like

Can you send me a this type of page file?
So that i can Understand clearly. It will be helpfull