How To Make The DropDownList Required

The DropDownList enables you to initialize it by using the input or the select element. In cases where selection from the DropDownList is mandatory initialize it from an input or select element with a required attribute. The example below uses the Kendo Validator to display the validation message.

    <form id="myForm" action="someAction" method="post">
      <input id="ddl" />
    </form>
    <button id="submitBtn" type="submit" class="k-button">Submit</button>
    <p></p>
    <button id="submitBtn" type="submit" class="k-button">Submit</button>
    <script>
      $("#ddl").kendoDropDownList({
        dataTextField: "text",
        dataValueField: "value",
        dataSource: [
          { text: "Black", value: "1" },
          { text: "Orange", value: "2" },
          { text: "Grey", value: "3" }
        ],
        optionLabel: "Select an option",
      });

      $("#submitBtn").click(function () {
          var validator = $("#myForm").kendoValidator().data('kendoValidator');
          validator.validate();
      });
    </script>

See Also

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

In this article
Not finding the help you need? Improve this article