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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dinesh SanthalingamPosted Dec 22, 2016, 6:06 AM
MayankPosted Dec 22, 2016, 5:09 AM
@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; }
Jasbeer SinghPosted Dec 21, 2016, 12:55 AM
Ramnath BodkePosted Dec 15, 2016, 6:24 AM
Ketan PatelPosted Dec 15, 2016, 6:11 AM
Ketan PatelPosted Dec 15, 2016, 5:57 AM
Dinesh SanthalingamPosted Dec 15, 2016, 5:53 AM
Harshal PatilPosted Dec 15, 2016, 5:39 AM
var re = /([A-Z0-9a-z_-][^@])+?@[^$#<>?]+?\.[\w]{2,4}/.test(this.value);
if(!re) {
$('#error').show();
} else {
$('#error').hide();
}
})
Harshal PatilPosted Dec 15, 2016, 5:36 AM
var re = /([A-Z0-9a-z_-][^@])+?@[^$#<>?]+?\.[\w]{2,4}/.test(this.value);
if(!re) {
$('#error').show();
} else {
$('#error').hide();
}
})
Bikesh SrivastavaPosted Nov 30, 2016, 8:54 AM
Dinesh SanthalingamPosted Nov 30, 2016, 8:16 AM
Prateek SinglaPosted Nov 30, 2016, 3:46 AM
Khaja MoizuddinPosted Nov 30, 2016, 3:42 AM
Dilip GuptaPosted Nov 30, 2016, 3:06 AM
Pooja ChowdhuryPosted Nov 30, 2016, 2:56 AM
Dilip GuptaPosted Nov 30, 2016, 2:52 AM