proceed to another page after choosing specific dates for submission

I have created the following code to build a booking calendar. I would like it so that when I click on submit, it will redirect to a different page by navigating. The function should check if the start date is greater than the current date and the end date is greater than the start date - if true, then navigate to a different page.

Thank you in advance!

<div class="container">
  <div class="row-center">
    <div class="jumbotron">
      <div class="row">
        <div class="col-md-4 col-sm-4">
          <h4 class="red">Start Date</h4>
          <input name="start" type="date" class="form-control " placeholder="Start date">
        </div>
        <div class="col-md-4 col-sm-4">
          <h4 class="red">End Date</h4>
          <input name="end" type="date" class="form-control" placeholder="End date">
        </div>
        <div class="col-md-3 col-sm-2">
          <input id="btnOpen" class="btn btn1 btn-success" type="submit" value="Submit">
        </div>
      </div>
    </div>
  </div>
</div>

Answer №1

I couldn't locate any click-triggered method in the example you provided.

If you're unsure how to implement it, I can guide you through it.

Revise your HTML as follows:

<input id="btnOpen" class="btn btn1 btn-success" type="submit" value="Submit" (click)="submitClicked()">

In your .ts file, create a function that will execute upon button click. This function is named submitClicked(). Here's an example of what the code could look like:

submitClicked() {
  // Implement the logic for this function to execute when the submit button is clicked
  // You may need something along these lines
  if(todayDate > start && todayDate < end){
    // Redirect to another page
  }
}

If you're uncertain about comparing dates or navigating to another page, consider searching online for more information.

Given the lack of clarity in the question and considering your experience level, I've broken down the steps to help you grasp the concept and proceed independently.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unraveling the Mysteries Behind the .next() Method in Angular

import { Component, Input, Output, EventEmitter } from '@angular/core'; var customInputCss = "app/css/ui/custom-input.css"; var customInputTemplate = "app/partials/custom-input.html"; @Component({ selector: 'custom-input', sty ...

tips for fetching information from sources beyond observable patterns

Is there a way to retrieve the value of this.dealType outside of the this.trasactionService.transactionEvent$ subscription? I need to access the data and value of this.dealType elsewhere, any help would be appreciated. While it has a value inside the this ...

Issue: The parameter "data" is not recognized as a valid Document. The input does not match the requirements of a typical JavaScript object

I encountered the following issue: Error: Argument "data" is not a valid Document. Input is not a plain JavaScript object. while attempting to update a document using firebase admin SDK. Below is the TypeScript snippet: var myDoc = new MyDoc(); myDo ...

Pass the identical event to multiple functions in Angular 2

On my homepage, there is a search form with an input box and select dropdown for users to search for other users by location or using html5 geolocation. When a user visits the page for the first time, they are prompted to allow the app to access their loca ...

Adding an Icon in p-autoComplete with PrimeNG in Angular 10

Is there a way to insert an icon within the primeng p-autoComplete component? <div class="p-mr-2 p-input"> <p-autoComplete styleClass="p-autocomplete-list-item" [(ngModel)]="location" [suggestions]="resul ...

Tips for implementing a reusable component in Angular 2

Within my module.ts file, @NgModule({ imports: [ BrowserModule, RouterModule.forRoot([ { path: '', component:AppComponent}, { path: 'login', component:AppComponent} ]) ], declarations: [ AppComponent,Mainapp ...

Tricks for simulating e.preventDefault in Angular

Creating Test Cases for a Method <input type="number" min="10" max="100" (keydown)="checkLength1($event,inputNumber)"#inputNumber/> ts file checkLength1(e: { key: string | number; keyCode: number; preventDef ...

Can you explain the mechanics behind the functionalities of @angular and @type dependencies?

This inquiry may have been raised before, but I couldn't uncover all the solutions. If that's the case, my apologies. I have a good grasp on how package.json and dependencies / dev-dependencies function in Node applications. Currently delving i ...

Issue with displaying selected value and options in Mat-select when using formarray - Reactive forms in Angular

I've been working on the code below to create dropdowns, but I'm having trouble getting the selected value and options to show up in the dropdowns. Can you help me figure out what's wrong with the code? Component code testForm: FormGroup; ...

The alignment of navbar links to the right is off in Bootstrap 4 and Angular 5

https://i.sstatic.net/UacKS.pngI am having an issue while working on my first application using bootstrap 4 and angular 5. The navbar links that should be aligned to the right are appearing on the left side instead. <nav class="navbar navbar-expand-md ...

What is the best way to extract and display data from an API response object in my

{ "_metadata": { "uid": "someuid" }, "reference": [ { "locale": "en-us", ... bunch of similar key:value "close_icon_size" ...

What is the best way to customize column width in AG-Grid?

I am looking for a way to dynamically set column width in my table. I have provided a stackblitz example which demonstrates that when changing the screen size, only the table border adjusts, but not the column widths. Is there a way to also change the col ...

What are the necessary peer dependencies for Angular-compatible projects?

In the process of integrating RxJS as a peer dependency for my Angular 6 project, I encountered an interesting declaration method. Take, for instance, angular/flex-layout, which declares its RxJS dependency in this manner: "requiredAngularVersion": ">= ...

Troubleshooting the issue with mocking the useTranslation function for i18n in JEST

Currently, I am facing an issue with my react component that utilizes translations from i18next. Despite trying to create tests for it using JEST, nothing seems to be getting translated. I attempted to mock the useTranslation function as shown below: cons ...

Choose all the checkboxes that use Knockout JS

Struggling with implementing a "select all" checkbox feature as a Junior developer on a complex project utilizing knockout.Js and Typescript. I can't seem to figure out how to select all existing checkboxes. Here is the HTML: <td> <inp ...

I'm perplexed as to why I'm receiving null for my context. Could it be due to a TypeError

Recently diving into Next Js and TypeScript, I encountered the following error: Unhandled Runtime Error TypeError: this.context is null Here's a snippet from my Layout.tsx file: import { FC } from 'react' import { Head } from 'next/d ...

Incorporating a skeletal design effect into a table featuring sorting and pagination options

Is there a way to implement the Skeleton effect in a MUI table that only requires sorting and pagination functionalities? I tried using the 'loading' hook with fake data fetching and a 3-second delay, but it doesn't seem to work with DataGri ...

Unexpected expression after upgrading to TypeScript 3.7.2 was encountered, file expected.ts(1109)

After updating TypeScript from version 3.6.x to 3.7.2, I started using optional chaining in my code. However, I encountered a peculiar error. Error message: Expression expected.ts(1109) This error appeared in both my (vim, VSCode) IDE, even though the ...

When attempting to retrieve information from the API, an error occurred stating that property 'subscribe' is not found in type 'void'

I've attempted to use this code for fetching data from an API. Below is the content of my product.service.ts file: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { map, Observ ...

Deploying an Angular-cli project to Digital Ocean

I am encountering an issue while trying to run my Angular 2 app on Digital Ocean. Despite successfully deploying my app on a cloud server, I am unable to connect to it on the specified port as the server does not respond. This is puzzling me as I have be ...