When i type an email in a textbox if it is not in correct format then it will be shown an error instantly not after button click.( i want to use this code in my asp.net Textbox.)
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pooja ChowdhuryRank #3,615 · 403 reputationPosted Nov 29, 2016, 9:56 PM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Dec 22, 2016, 1:06 AM EST
Dilip GuptaRank #2,085 · 690 reputationPosted Nov 29, 2016, 9:52 PM EST
Dilip GuptaRank #2,085 · 690 reputationPosted Nov 29, 2016, 10:06 PM EST
Khaja MoizuddinRank #270 · 9.4K reputationPosted Nov 29, 2016, 10:42 PM EST
Prateek SinglaRank #1,452 · 1.1K reputationPosted Nov 29, 2016, 10:46 PM EST
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Nov 30, 2016, 3:16 AM EST
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Nov 30, 2016, 3:54 AM EST
Harshal PatilRank #9,687 · 203 reputationPosted Dec 15, 2016, 12:36 AM EST
var re = /([A-Z0-9a-z_-][^@])+?@[^$#<>?]+?\.[\w]{2,4}/.test(this.value);
if(!re) {
$('#error').show();
} else {
$('#error').hide();
}
})
Harshal PatilRank #9,687 · 203 reputationPosted Dec 15, 2016, 12:39 AM EST
var re = /([A-Z0-9a-z_-][^@])+?@[^$#<>?]+?\.[\w]{2,4}/.test(this.value);
if(!re) {
$('#error').show();
} else {
$('#error').hide();
}
})
Dinesh SanthalingamRank #2,085 · 690 reputationPosted Dec 15, 2016, 12:53 AM EST
Ketan Patel47 reputationPosted Dec 15, 2016, 12:57 AM EST
Ketan Patel47 reputationPosted Dec 15, 2016, 1:11 AM EST
Ramnath BodkeRank #7,130 · 248 reputationPosted Dec 15, 2016, 1:24 AM EST
Jasbeer SinghRank #1,010 · 2K reputationPosted Dec 20, 2016, 7:55 PM EST
MayankRank #4,018 · 371 reputationPosted Dec 22, 2016, 12:09 AM EST
@model ValidationsMvc.Models.DataModel
@{
ViewBag.Title = "Index";
}
Index
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.ValidationSummary(true)
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
}
Model
[Required(ErrorMessage = "Field can't be empty")]
[DataType(DataType.EmailAddress, ErrorMessage = "E-mail is not valid")]
public string Email { get; set; }