I have a form that validates the fields when trying to send information, but I have a "novapagina" option where I would not like to validate the fields, would that be possible?
In views
<div class="container droppedHover">
<br/>
<div class="relative">
<img src="~/Content/images/Checkmark.fw.png" alt="logo" class="img-circle">
</div>
<br/>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.ValidationSummary(true)
<div class="row">
<div class="span6">
@Html.TextBoxFor(x => x.login, new { placeholder = "correo electrónico", @class = "form-control input-lg" })
@Html.ValidationMessageFor(x => x.login)
@Html.TextBoxFor(x => x.senha, new { placeholder = "password", @class = "form-control input-lg", type = "password" })
@Html.ValidationMessageFor(x => x.senha)
</div>
</div>
<br />
<div class="row">
<div class="span6">
<button class="btn btn-lg btn-block btn-primary " type="submit" name="opcao" value="pesquisar" >Login...</button>
<button class="btn btn-lg btn-block btn-warning " type="submit" name="opcao" value="novapagina" >¿Olvidó la contraseña?</button>
</div>
</div>
if (TempData["msg"] != null)
{
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>@TempData["msg"]</strong>
</div>
}
else if (TempData["erro"] != null)
{
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>@TempData["erro"]</strong>
</div>
}
}
</div>
No Controller
[HttpPost]
public ActionResult Index()
{
string opcao = Request["opcao"];
if (opcao == "novapagina")
{
return RedirectToAction("index", "RecuperaSenha");
}
else
{
//aqui vai pesquisar o login é senha
return View();
}
}