asp.net mvc 4 - How to validation kendo ui dropdown list -
i having problem validating kendo dropdownlist if user select "please select" option. please let me how can trigger validation
here code have far:
@html.labelfor(model => model.consumergenderid) @(html.kendo().dropdownlist() .name("gender") .htmlattributes(new { @style = "align:center; font-size:12px; width:208px; length:35px" }) .optionlabel("please select") .value("-1") .datatextfield("optionname") .datavaluefield("optionid") .datasource(source => { source.read(read => { read.action("getgenderstatus", "consumerdetails"); }); }) ) @html.validationmessagefor(model => model.givenname1, " ") </div>
model
required(errormessage = "please select gender")] [uihint("gridforeignkey")] [displayname("gender")] public int consumergenderid { get; set; } public string consumergendername { get; set;
}
try matching names of 2 fields. eg "gender" , givenname1 not equivalent right there enough keep validation firing if weren't kendo dropdown.
perhaps try use dropdownfor it's little easier keep track of.
@html.kendo().dropdownlistfor(m=>m.givenname1) @html.validationmessagefor(m=>m.givenname1)
Comments
Post a Comment