I have a registration form and a login form for users. I want validation on the Registration form obviously, but I do not want it on the login form. I've noticed it validates things with JS on the login form. I.E it doesn't even try to submit the form until the user types in a password of length over 5 (I.E what I set in the validation). How do I disable this?
Login form:
@using (Html.BeginForm("Login", "Users", FormMethod.Post, new { @class = "well"})) {
<legend>Login</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Email)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Email, new { @placeholder = "Email" })
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Password, new { @placeholder = "Password" })
</div>
<label class="checkbox">
@Html.CheckBoxFor(model => model.HasRememberMeOn) Remember me
</label>
if (ViewData["ErrorMessage"] != null)
{
<p>@ViewData["ErrorMessage"]</p>
}
<p>
<input type="submit" value="Login" />
</p>
}
Model:
[Required]
[StringLength(20, MinimumLength=5)]
[Username(ErrorMessage="Username must: Contain at least one letter, no spaces, no special characters")]
public string Username { get; set; }
[NotMapped]
[StringLength(25, MinimumLength = 5)]
public string Password { get; set; }
[Required(ErrorMessage="Password is required")]
public string HashedPassword { get; set; }
[Required]
[StringLength(50, MinimumLength = 3)]
public string Email { get; set; }
[NotMapped]
[Compare("Email", ErrorMessage = "Your emails don't match")]
[DisplayName("Confirm email")]
public string Email2 { get; set; }
public Boolean IsActivated { get; set; }
[DisplayName("Date joined")]
public DateTime DateCreated { get; set; }
[Required]
[StringLength(50, MinimumLength = 2)]
[DisplayName("Real name")]
public string Name { get; set; }