asp.net mvc - MVC Client side validation? -
i have 3 textboxes ...one day, second month , third year. want use mvc validation check if 1 of field empty , show *. possible on button submit display 1 error message if 1 of fields empty?
<div class="form-group"> <label for="dateofbirth" class="control-label col-lg-5"> @html.label(@betxonline.translationprovider.instance.gettranslationmessage("birthdate")): @html.validationmessage("*") </label> <div class="col-lg-2"> @html.textboxfor(m => m.register.day, new { id = "day_birthdate", @class = "form-control" }) </div> <div class="col-lg-2"> @html.textboxfor(m => m.register.month, new { id = "month_birthdate", @class = "form-control" }) </div> <div class="col-lg-3"> @html.textboxfor(m => m.register.year, new { id = "year_birthdate", @class = "form-control" }) </div>
you can add @validationmessagefor fields under same label.
<label for="dateofbirth" class="control-label col-lg-5"> @html.label(@betxonline.translationprovider.instance.gettranslationmessage("birthdate")) : @html.validationmessagefor(m => m.register.day,"", new { @class = "text-danger" }) @html.validationmessagefor(m => m.register.month,"", new { @class = "text-danger" }) @html.validationmessagefor(m => m.register.year,"", new { @class = "text-danger" }) </label>
Comments
Post a Comment