Drupal 8 Telephone Number Field Validation

Submitted by gazza on Thu, 14/02/2019 - 12:15
Drupal 8 Telephone number Field Validation

Recently I have seen an increase in spam form submissions even with using Google reCAPTCHA . Being that most of the Drupal sites I develop are for small to medium sized local businesses, I tend to add a telephone number field to their website contact forms.

Even by making the Name, Email, Telephone number and message fields required to be filled in, and using the Captcha, still many spammy form submissions get through. To try to reduce this further I have implemented the amazing telephone validation module which provides field validation to Drupal core Telephone field and tel form element which uses the libphonenumber composer package for validation.

It is a snip to install and setup. Simpy use composer to install the module and the library dependency then enable the telephone validation check box in the phone number field settings: