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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -