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
Post a Comment