Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make field required with k-ng-model?

I have validation issue if i use k-ng-model on field that field is not required with Angularjs validation , User can submit the form so below code field is required even i dont select the value user can still submit the form.. Any idea how to solve it ?

main.html

<div class="row">
   <div class="form-group col-md-12">
     <label for="themesList" class="required col-md-4">Themes:</label>
        <div class="col-md-8">
         <select class="multiselect" kendo-multi-select="themes"
                                k-options="challengThemesOptions" data-text-field="'text'"
                                data-value-field="'id'" name="themesList"
                                k-ng-model="challengesDTO.themesKyList" required
                                id="themesList"></select>
          <p class="text-danger" ng-show="addChallengeForm.themesList.$touched && ddChallengeForm.themesList.$error.required">Theme(s) is required</p>
        </div>
    </div>
  </div>
like image 836
aftab Avatar asked Mar 16 '23 11:03

aftab


1 Answers

You can use ng-model with k-ng-model, Try assigning ng-model to a seperate variable and use ng-required.

<select class="multiselect" kendo-multi-select="themes"
                            k-options="challengThemesOptions" data-text-field="'text'"
                            data-value-field="'id'" name="themesList"
                            k-ng-model="challengesDTO.themesKyList" ng-model="challengesDTO.themesKyListValue" ng-required
                            id="themesList"></select>
like image 199
JEROM JOY Avatar answered Mar 29 '23 19:03

JEROM JOY