• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Thymeleaf - Add leading zero to date field if day or month is entered as D/M instead of DD/MM

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I have this code for date entry in a Thymeleaf template:

 
   

The date format should be DD/MM/YYYY but currently if something like  D/M/YYYY is entered no validation catches this and it causes an error in  a downstream application. I'd like to add some functionality where a  leading zero is added if the length of D or M are 1.

An example of what I'm trying to do but done with JSP and JavaScript are as follows:

 
Think maybe I could do something along the lines of but not quite this:

 
Bartender
Posts: 653
14
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why does it cause a problem downstream?  Maybe you should handle that on the backend or have a drop list on the frontend.
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic