How to validate fields using jquery in asp.net mvc 3 razor -


here code:

@using (html.beginform("register", "user", formmethod.post, new { id = "registerform" }))       {      @html.textboxfor(m => m.emailaddress,                        new { size = "40",                              @onchange = "usernameval();",                              @tabindex = "1" }) }  $("#registerform").validate({          rules: {             emailaddress: {                 required: true             }         },         messages: {             emailaddress: {                 required: "<br/> please enter email address"             }         }     }); 

why don't use annotation validate fields? it's easier , cleaner, can below:

 public class mymodel  {      [required(errormessage = "please enter email address")]      public string email { get; set; }  } 

Comments

Popular posts from this blog

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

iphone - Using nested NSDictionary with Picker -

javascript - Iterate over array and calculate average values of array-parts -