Responsive WordPress Theme – Caliber

A theme with simple controls and limitless potential. Work fast and build an amazing website!   Find out more »

UpThemes – Beautiful WordPress Themes

Create a site your church, gallery, newspaper, blog, recipes, band and more!   See the themes »

Need a little help?  Find answers quickly by searching the forum.
Group Admins
  • jeffw

Support for: Unite – WordPress Business, Magazine Theme

Unite (WordPress)

Public Group  |  active 4 years, 5 months ago ago
Viewing post 1 to 3 (3 total posts)

Contact form – email in uppercase is not valid

  • sambasanchez

    said

    is there a way on the contact form for the user to type uppercase emails?
    When I type a valid email in uppercase letters I get “Please enter a valid e-mail address.”

    It’s not that I will use uppercase for it, but there are some people out there who will not know what to do. The system also doesn’t specify the error.

    Thanks in advance.

    Samba.

  • jeffw

    said

    You would need to customise the validation function in the ‘contact-send.php’ file…

    function ValidateEmail($email){
     
      $regex = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^";
      $eregi = preg_replace($regex,'', trim($email));
        
      return empty($eregi) ? true : false;
    }

    The validation string ($regex) is a regular expression. I think something like this should do what you want…

    function ValidateEmail($email){
     
      $regex = "^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,3})$^";
      $eregi = preg_replace($regex,'', trim($email));
        
      return empty($eregi) ? true : false;
    }

    Keep in mind that if you modify core theme files then each time you update the theme you will need to make all of those modifications again to the updated theme files.

    References:
    http://php.net/manual/en/book.pcre.php

  • sambasanchez

    said

    Thank you for your quick reply!!!
    It worked like a charm!

Viewing post 1 to 3 (3 total posts)