Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
ionic 6 ion-datetime restricting dates to just max 2 dates

I am using ionic 6 for ion-datetime with property multiple="true". I want to make sure that user cannot select more than 2 dates. and if user selects the 3rd date then i want to remove the oldest date automatically rather throwing a validation error. The code is like below:

  <ion-datetime presentation="date" multiple="true" preferWheel="false" [(ngModel)]="packageEstimatedDated" (ionChange)="validateDates()"></ion-datetime>

for .ts

packageEstimatedDated
async validateDates(){
    console.log("selected dates length:", this.packageEstimatedDated.length)
    
    if(this.packageEstimatedDated.length === 3){
      console.log("after remove extra date", this.packageEstimatedDated)
      this.packageEstimatedDated.splice(0,1)
      console.log("after removed", this.packageEstimatedDated)
    }
  }

The problem is that even the splice is removing the element but it still not really. Here is the output i see when i select 4 dates one by one:

selected dates length: 1
new-order.page.ts:61 selected dates length: 2
new-order.page.ts:61 selected dates length: 3
new-order.page.ts:72 after remove extra date (3) ['2022-08-10', '2022-08-18', '2022-08-23']
new-order.page.ts:74 after removed (2) ['2022-08-18', '2022-08-23']
new-order.page.ts:61 selected dates length: 4
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!