7 Jun 20232 minutes to read

DatePicker is a form control and therefore its value to be validated before processing. Client side validation provides a better user experience by responding quickly at browser level. Most common client side validation plugin is jQuery Validation.

DatePicker supports this validation by built-in, so you can do client validation with simple steps to validate and respond validation message. The jQuery validate plugin rules and custom methods can be used in the DatePicker control with the help of two properties,validationRules and validationMessage.

Before using those properties, you need to add the jQuery validate plugin to your HTML page.

Refer the below jQuery validation plugin script after jQuery script reference.

  • HTML
  • <script src=""></script>
  • HTML
  • <!--form to submit-->
            <!--input element to create DatePicker-->
            <input id="datePicker" />
            <!-- submit button -->
            <input type="submit" value="submit" />

    jQuery validation library contains some default settings for validating the form. By default, it ignores hidden elements in from validation. If validation gets fail, in-built “error” class will be added to corresponding element. Here you can specify a custom class with your own style using “errorClass” API and you can place the error message in necessary position using “errorPlacement” API. Refer following code block to customize the default jQuery validation settings.

  • $.validator.setDefaults({
               //if we don’t set custom class, default “error” class will be added
               errorClass: 'e-validation-error',
               //it specifies the error message display position
               errorPlacement: function (error, element) {
  • $(function () {
                // creates DatePicker from input
                    validationRules: { required: true },// sets the field to be required
                    validationMessage: { required: "Required Date value" } // sets validation message


    jQuery validation works only within the form element.