0
var pattern = /^\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i;
var mail = $('#'+form+' input[name=email]').val();

var form = $(this).closest('section').attr('id'); //ID секции из которой было отправлено письмо. Нужен для того чтобы заполнять блок с результатом
$('#'+form+' .result').removeClass().addClass('result');//деактивация блока с результатами

if (!pattern.test(mail)) {
    $('#'+form+' .result').addClass("alert alert-warning").html('You did not fill in the e-mail field!');
} 

I tried to make validation with RegExp, bur it's not working.

skolind
  • 1,724
  • 6
  • 28
  • 51
  • not working is a really bad error description – Thallius Jan 28 '21 at 13:21
  • if you test the regex on https://regexr.com/ it seems to be working just fine. I think there is another issue with your code, then the regex. – skolind Jan 28 '21 at 13:22
  • 1
    if this is the whole code, then you should get error for using `form` variable before definition, if its not then explain more about . – AbbasEbadian Jan 28 '21 at 13:32

0 Answers0