I have a very simple newsletter subscription form :
@using (Ajax.BeginForm("Register", "Home", new AjaxOptions
{
Confirm = "confirm?",
HttpMethod = "Post",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "response"
}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div id="response">
<div class="form-group">
@Html.TextBoxFor(model => model.Email, new { @class = "form-control", @placeholder = "insert email" })
@Html.ValidationMessageFor(model => model.Email)
</div>
<div class="form-group">
<input type="submit" id="submit" value="subscribe" class="btn btn-default" />
</div>
</div>
}
The email field needs to be filled, and be a valid email. The problem is that as soon as I start typing inside the textbox, validation fires, and the message "email is invalid" pops out. This is quite annoying. Is there a way to fire validation when clicking on submit button, instead of every single textbox change? Thank you.