Open In App

How to Restrict User to Enter Date Manually in Date Field using AngularJS ?

In this article, we will see how to restrict the user to enter the date manually in the date field using AngularJS, along with understanding its implementation through the example.

Approach:



Example: This example illustrates restricting the user to enter the date manually in the date field using AngularJS.




<div style="text-align:center">
    <h1 style="color:green">GeeksforGeeks</h1>
    <h3>
        Restricting the user to enter
        date manually in date field
    </h3>
    <label for="vote">Select a date:</label>
    <input type="date" id="vote" name="vote" 
        (keydown)="disableDate()">
</div>




import { Component } from "@angular/core";
@Component({
    selector: "my-app",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.css"],
})
export class AppComponent {
    disableDate() {
        return false;
    }
}




import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
  
import { AppComponent } from "./app.component";
  
@NgModule({
    imports: [BrowserModule, FormsModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
export class AppModule { }

Output:



 


Article Tags :