asp.net mvc 3 - Validation for textbox in MVC3 -
i need help. working mvc3-razor application. need validate textbox on view (.cshtml file) in such way that, starting 2 characters must "pr" , 4th character must "2". requirement. how achieve functionality? suggestions, great help. precious time.
model
public class registermodel { public int id { get; set; } [regularexpression(@"^pr[a-za-z0-9]2([a-za-z0-9]*)$", errormessage = "please enter valid name.")] [required(errormessage = "name required.")] public string name { get; set; } }
view
@using (html.beginform("dymaniccontrollerpage", "test", formmethod.post, new { id = "frmindex" })) { <div> @html.labelfor(m => m.name) @html.textboxfor(m => m.name) @html.validationmessagefor(m => m.name) </div> }
Comments
Post a Comment