0
Answer

jquery validation attribute not working

I have two models

public class UserDetail { [Required] public string username { get; set; } 
[Required] public string name { get; set; }
public LogInDetail LogInDetail { get; set; } }

and

public class LogInDetail { 
[Required] public string username { get; set; }
[Required] public string password { get; set; }
public UserDetail UserDetail { get; set; } }

and a view having model UserDetail

@using (Html.BeginForm()) 
{ @Html.LabelFor(m=>m.LogInDetail.username)
@Html.EditorFor(m=>m.LogInDetail.username)
@Html.ValidationMessageFor(m=>m.LogInDetail.username)
@Html.LabelFor(m=>m.LogInDetail.password)
@Html.EditorFor(m=>m.LogInDetail.password)
@Html.ValidationMessageFor(m=>m.LogInDetail.password)
<input type="submit" value="Submit" /> }

if i try to submit the form without any entry it should show client side validation (as i have added [Required] attribute to the properties of LogInDetails). I have also added jquery library for validation. But i am not getting any client side validation error message. Please help me