All Components

Forms Support

You can use the DateInput in Template-driven and Reactive forms.

Template-Driven Forms

The template-driven forms enable you to bind the DateInput to the model by using the ngModel directive.

export interface User {
       birthDate: Date;
   }

   @Component({
       selector: 'my-app',
       template: `
           <form #form="ngForm">
               <div class="example-config">
                   <p>The selected birth date is <strong>{{ user.birthDate | kendoDate: 'M/d/yyyy' }}</strong></p>
                   <p *ngIf="!form.valid">
                       Only values between 1/1/1917 and 12/31/2000 are valid!
                   </p>
               </div>
               <label>
                   Select Birthdate:
                   <kendo-dateinput
                       name="birthDate"
                       [(ngModel)]="user.birthDate"
                       [min]="min"
                       [max]="max"
                   ></kendo-dateinput>
               </label>
           </form>
       `
   })
   class AppComponent implements OnInit {
       public user: User;
       public min: Date = new Date(1917, 0, 1);
       public max: Date = new Date(2000, 11, 31);
       ngOnInit() {
           this.user = {
               birthDate: new Date(1990, 0, 1)
           };
       }
   }

Reactive Forms

The FormGroup decorator provides a way to render reactive forms. For more details, refer to the Angular documentation.

import {
       FormsModule,
       ReactiveFormsModule,
       FormGroup,
       FormControl
   } from '@angular/forms';

   @Component({
       selector: 'my-app',
       template: `
           <form [formGroup]="myForm">
               <div class="example-config">
                   <p>The form is valid: <strong>{{myForm.controls.birthDate.valid}}</strong></p>
                   <p>The form.birthDate value is: <strong>{{myForm.controls.birthDate.value | kendoDate: 'M/d/yyyy'}}</strong></p>
                   <p *ngIf="!myForm.valid">
                       Only values between 1/1/1917 and 12/31/2000 are valid!
                   </p>
               </div>

               <label>
                   Select Birthdate:
                   <kendo-dateinput
                       formControlName="birthDate"
                       [min]="min"
                       [max]="max"
                       required
                   ></kendo-dateinput>
               </label>
           </form>
       `
   })
   class AppComponent {
       public min: Date = new Date(1917, 0, 1);
       public max: Date = new Date(2000, 11, 31);

       public myForm: FormGroup = new FormGroup({
           birthDate: new FormControl(new Date(2000, 10, 10))
       });
   }
In this article