3
I have a jQuery code on the CSHTML page and I’m having trouble validating the email with a regular expression, because the @
is a Razor command in .NET. How to proceed to resolve this issue?
Follows the script:
$("#formEsqueceuSenha").submit(function(event) {
$(".message").hide();
$(".Error").hide();
var sEmail = $("#email").val();
if ((sEmail == '') || (sEmail == null)) {
$("#email").focus();
$(".message")
.text('Por favor, informe um email válido.')
.show();
event.preventDefault();
} else {
var filtro = "/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i";
if (!filtro.test(sEmail)) {
$("#email").focus();
$(".message")
.text('E-mail digitado esta invalido. Por favor corrigir.')
.show();
event.preventDefault();
} else {
return;
}
}
});
As the research does not help I did not find but I’m sure this was asked recently. If I’m not mistaken it was @Gypsy who replied, but I could be wrong.
– Maniero
@Bigown In my opinion, that question is already answered.
– Leonel Sanches da Silva