My view has a textbox(Email) and a submit button.
@using (Html.BeginForm("FindMyDetail", "ResetPassword", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Enter your email.</h4>
@Html.ValidationSummary(false, "", new { @class = "alert alert-danger" })
@Html.ValidationMessageFor(m=>m.Email)
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@*@Html.TextBoxFor(m => m.Email, new { @class = "form-control", @value = @Html.DisplayFor(m => m.Email) })*@
@Html.TextBoxFor(m => m.Email, true, htmlAttributes: new { @class = "form-control", placeholder = "Enter Email Id you used to register" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Email Link" />
</div>
</div>
}
I have to show multiple validation messages in a view of MVC web app.
Case1 : Show validation message to enter email id when textbox left empty.
Case2 : Submit button triggers a mail if email exists .If mail fails(false) a validation message that email does not exist should come. On click of submit button takes to a controller which triggers a mail to given email. If succesfull i will return a different view with success message else i will return the same view (EmailLink view)
In asp.net webforms implementing this seems easy but looks very different and am puzzled how to implement this in MVC since am new to it.
EDIT: I need it to be implemented using Custom Validation.Not using data anotations.