WP Contact Form 7 create a custom URL validation

In WP the Contact Form 7 is a standout amongst the most famous modules for making contact shapes. One thing that you may have seen however is that the approval of the URL field won’t fall flat when you anticipate that they will come up short. For instance, with the URL estimation of, the module will think about this as a substantial URL, despite the fact that, the URL esteem is missing best level space part. The answer to this issue is to have a custom approval for the URL field. This article will demonstrate to you generally accepted methods to accomplish that.

Including our own URL approval utilizing wpcf7_is_url channel

Our custom URL approval will be genuinely straightforward. On the off chance that the default URL approval of the module is legitimate, we complete one extra approval utilizing a regex articulation that will attempt to approve a space name. There are numerous standard articulations on the web for space name approval, the one I use in the code beneath appears to work entirely well. On the off chance that regex approval bombs, at that point we set $result to FALSE, which will flag the module to show “URL appears to be invalid.” blunder message.

In the functions.php of your theme, add the following code:

function ikodes_contact7_check( $result, $url ) 
  if ($result)
    $regex='@^(https?://)?(www.)?([a-z0-9]([a-z0-9]|(-[a-z0-9]))*.)+[a-z][email protected]';  
    if (!preg_match($regex,$url)) $result=FALSE;	  
  return $result;
add_filter( 'wpcf7_is_url', 'ikodes_contact7_check', 10, 2 );

Related Posts

October 12, 2019

History of WordPress

Would you like to think about the historical backdrop of WordPress? On the off chance that you are beginning a WordPress blog or site today, at that point you see a prevalent web designer which fueled over 32% of all sites on the web. In this article, we need to investigate the historical backdrop of

October 2, 2019

Magento 2.3 release: New features that will amaze you

At the Magento Imagine Conference in April 2018, Magento declared the following critical discharge on the Magento stage – Magento 2.3. It has gigantic highlights, improvements, and back-end upgrades. It is scheduled for discharge toward the year’s end. The following are the new highlights of the new, yet to be discharged Magento 2.3. 1. Dynamic