In general, I check the string for 2 conditions with a regular schedule. I can not understand what I am doing wrong. You need to check to enter either a string of letters or email.
Tell me why the function gives two values?
function is_valid(login) { if (login.match(/^((([a-z0-9_\.-]+)@([a-z0-9_\.-]+)\.([az\.]{2,6})) | ([a-z0-9_-]{3,16}))$/gi) != null) { login = login.match(/^((([a-z0-9_\.-]+)@([a-z0-9_\.-]+)\.([az\.]{2,6})) | ([a-z0-9_-]{3,16}))$/gi).join(''); return login; } else { $('#inLogin').css('border', 'red 1px solid'); error = 2; return; } console.log(login); console.log(error); }
|spaces - Visman|caused this behavior? Thank. - excellprojIgnore whitespacein relys js not to ignore spaces. - Visman