Edit this page

Validate Lists by Using Required Attributes

The following example demonstrates how to validate a DropDownList in AngularJS applications by using a required attribute along with ng-model.

<div ng-app="inputExample">
    <script>
     angular.module('inputExample', [ "kendo.directives" ])
       .controller('ExampleController', ['$scope', function($scope) {
         $scope.user = {country: ''};
       }]);
    </script>

  <div ng-controller="ExampleController">
    <form name="myForm">
      <label>
          Country:
          <select kendo-drop-down-list
                  k-option-label="'Select...'"
                  ng-model="user.country"
                  name="country"
                  required>
            <option>Albania</option>
            <option>Andorra</option>
            <option>Armenia</option>
            <option>Austria</option>
            <option>Azerbaijan</option>
            <option>Vatican City</option>
          </select>
      </label>
      <div role="alert">
        <span class="error" ng-show="myForm.country.$error.required">
         Required!</span>
      </div>
    </form>
    <hr>
    <tt>user = </tt><br/>
    <tt>myForm.country.$valid = </tt><br/>
    <tt>myForm.country.$error = </tt><br/>
  </div>
</div>

See Also

For more runnable examples on the Kendo UI DropDownList, browse its How To documentation folder.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy