• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

startdate,endDate validations how is it done?

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I have 2 date fields on form. StartDate(fromDate) and EndDate(toDate). Currently I have a calender image which is linked with javascript to click on date and it comes/populates on the text field. User cannot add the date directly in the text field.

But now the user should also be allowed to put the dates with hand type in these 2 fields and also could use the calender if they want to use (they can click on it and the date populates).
what is generally done in this case? The required format is mm/dd/yyyy format. But the user could also enter dd/mm/yyyy format. It the date is likely to be understood like 12/25/2005 it's ok. But if user enters by mistake dd/mm/yyyy like 25/12/2005 then it's an error. How is the format checked? How is it validated?

Is it checked with javascript at client side or checked in backend side in java application?
[ May 26, 2005: Message edited by: Bear Bibeault ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clientside validation with JavaScript is fallable and shouldn't be relied on. Always validate serverside.

To control the format of your dates why not change from two input fields to six - day, month and year for each of the two dates? That way rather than trying to anticipate how many combinations of possible date formats the user could enter you tell them which format your application requires.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:
Clientside validation with JavaScript is fallable and shouldn't be relied on. Always validate serverside.

To control the format of your dates why not change from two input fields to six - day, month and year for each of the two dates? That way rather than trying to anticipate how many combinations of possible date formats the user could enter you tell them which format your application requires.



Or better, 3 select lists for each date.
 
Liz Brown
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your suggestions. Do you know a sample code which already exists online?
 
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is going to be populating the date fields using the calendar. I don't know whether you're using a third-party component or not but there should be a way to capture and parse the return value from the calendar picker to populate the three separate fields rather than the single field.
 
Liz Brown
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we are supposed to use Javascript.
Does javascript automatically detect the format of Date?
If yes, any suggestions on how to check it?
 
Marshal
Posts: 67447
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript will use the format of "MM/DD/YYYY"

but how would you tell the difference bewteen

04/05/2005

are we talking April 5th or May 4th?

basically you need to state the date format on your form.

Eric
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So assuming your calendar picker returns a JavaScript date, just parse the date into the three values you need.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic