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


January 19, 2020

Why You Should Use WordPress as a Beginner

Along these lines, you plan on beginning another blog for yourself. There are several alternatives accessible for you to do as such. Nonetheless, still, a great many people disregard these alternatives and straightaway go for WordPress. All in all, what makes WordPress so prominent? Here are 15 extraordinary reasons why you ought to consider WordPress

January 18, 2020

Top 5 Hybrid Mobile App Frameworks for 2018

The fight between Best Hybrid Mobile App Frameworks in 2018 and top local app system is an endless one; both have their own advantages and disadvantages. While serving different customers from new businesses to ventures, one thing I learned is that picking among local and hybrid app advancement isn’t a simple errand. Everything relies upon