Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Email Regex Rate Topic   - - - - -

 
  • mohsin1631
  • Advanced Member
  • Members
  • Join Date: 18-May 22
  • 77 posts

Posted 26 July 2022 - 07:19 AM #1

Where is the email regex script in cs-cart??



 
  • CS-Cart team
  • CS-Cart support team
  • Moderators
  • Join Date: 04-Apr 11
  • 3943 posts

Posted 26 July 2022 - 02:17 PM #2

Hi!

 

Where is the email regex script in cs-cart??

In CS-Cart email is mainly checked at front-end:

 

js/core/src/core/Tygh/plugins/form_validator/index.js

        if (lbl.hasClass('cm-email')) {
            if (!$.is.email(elm.val()) && !$.is.blank(elm.val())) {
                _formMessage(_.tr('error_validator_email'), lbl);
                set_mark = true;
            }
        }

js/core/src/core/Tygh/core_methods.js

export const is = {
    email: function(email) {
        return /^([^@\s]+<?)([^@\s]*)@(([^@\.\s]+?)|([^@\s]+?\.[^@\s]+?))(>?)$/i.test(email) ? true : false;
    },

And from back-end:

 

app/functions/fn.common.php

function fn_validate_email($email, $show_error = false)
{
    $regex = '/^([^@\s]+<?)([^@\s]*)@(([^@\.\s]+?)|([^@\s]+?\.[^@\s]+?))(>?)$/';

    if (strlen($email) < 320 && preg_match($regex, stripslashes($email))) {
        return true;
    } elseif ($show_error) {
        fn_set_notification('E', __('error'), __('text_not_valid_email', array(
            '[email]' => $email,
        )));
    }

    return false;
}

Hope this helps.


Sincerely yours, CS-Cart Support Team

 

User guide       |  Developer documentation  |  Core API documentation