UK Phone Verification for Gravity Forms

By March 17, 2016Blog

spam numberThis is not an exact solution but a reasonable workaround. So you want to check that a phone number submitted on your gravity form is accurate. If you are living in the USA you have no problem as there is already an option for the (###)-###-#### numbers. For the UK you can choose international but there is no check here. Someone could type in 123 and that would go through.

This solution uses conditional logic and basically makes sure that the submitted number either starts with a 0 or 4, and is at least 11 digits long. This will not stop 07123456789 or such numbers but hopefully will cut down on spam numbers.

So basically add an HTML area below the phone input. Remove HTML from the field label then enter something like this in the main text area.

<div class=”validation_error”>
Please enter a valid phone number.

And then add CSS to your theme. I use this:
div.validation_error {
background-color: #FFDFE0;
margin-bottom: 6px !important;
padding: 6px 6px 4px 6px !important;
border-top: 1px solid #C89797;
border-bottom: 1px solid #C89797;
font-size: 18px !important;
padding-top:20px !important;
padding-bottom:20px !important;

This will make the error message look like a proper error.

Then for the HTML block, add conditional logic so that it appears when phone starts with 1,2,3,5,6,7,8,9 and if phone is less than 1000000000 (1 billion, 9 zeros) – but don’t put in commas. Add conditional logic at Advanced -> Enable Conditional Logic. Make sure to have “any” NOT “all”. Then add more conditions using the + button. It should end up looking like this.

gravity forms uk phone validation


When someone submits a false number this error will appear:
spam number

Leave a Reply