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

290
Views
How to check if the DateTime matches the required format while using HTML DateTime-Local

I am developing a web application in which I have multiple HTML fields of type datetime-local. Users should provide the value for this in the following format:

2022-04-01T14:44:53

Since it is a user-selectable field sometimes users are omitting final seconds for this field. Date time with missing seconds value:

2022-04-01T14:44:53 //missing final seconds :53

Is there any way I can validate the same in JavaScript? I am developing the application using Nuxtjs/Vuejs. Better if there is any way I can add the validation within my HTML element itself.

Following is my HTML element:

<input
v-model="specificDateTime"
type="datetime-local"
class="form-control"
title="Set Event Time"
value="2022-04-01T10:00:00"
step="1"
>

Please let me know if there is any possibility to validate datetime-local at the HTML level itself based on the format. If not how can I do the same in my JavaScript?

If I provide empty values to hour/minutes then I get the error message but if I make the seconds as empty then I do not get the error. How to make the seconds field to be required so if the user provide empty values then it should throw the error.

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!