Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
cfKismet #1
Date Validation
I'm trying to find some Coldfusion code that will allow me to validate a date
to make sure that it's in MM/DD/YY format and is actually a valid date.
Everything that I've read about IsDate says that it's faulty and doesn't check
to see if the date being checked is actually real. Is anyone aware of code that
does this?
cfKismet Guest
-
[PHP] Date Validation, Kinda'
Now that I'm thinking about it, what is your goal with this? Is it to make sure the date entered is within a certain range when compared to another... -
combo box date validation
Hi, As per our requirement, we need to put combo boxess for date input. we are giving the user to input as dd month year format from the given... -
Date Range Validation
Hello; CL_FRST (08/10/2004) and CL_LST (05/24/2005) holds the beginning and ending date of school calendar which is also prepopulated for every... -
Date Validation, Kinda'
Howdy, Has anyone written any date validation function or sequence. I have looked around, but haven't found anything. I am cobbling togather... -
date validation?
How to write an IsDate function that actually checks for a particular date format? Using try-catch on Convert.ToDateTime(sDate) doesn't catch... -
SafariTECH #2
Re: Date Validation
What version of CF? I haven't had any issues with IsDate, but you could also use IsValid with the date attribute
SafariTECH Guest
-
Dan Bracuk #3
Re: Date Validation
Not sure if it's still the case, but, in version 4.5 isDate("apr 31") would
return true. For cfKismet, if you are talking about a text input field, and
you have CF version 7, set the mask attribute to 99/99/99 and the validate
field to date.
Dan Bracuk Guest
-
cfKismet #4
Re: Date Validation
Sorry, I should have been more specific. The page that processes all of my
Coldfusion validation does it free-form as not all of my validation can be
accomplished through masks. Can someone confirm whether or not IsDate actually
works as intended in Coldfusion 7? (i.e. doesn't just validate the format, but
actually if its a real date or not)
cfKismet Guest
-
SafariTECH #5
Re: Date Validation
^^^ That's why I asked about version ... it's been ages since I have seen anything about improper date validations
SafariTECH Guest
-
Dan Bracuk #6
Re: Date Validation
isDate never validated format. It takes a string and returns true if it can
turn that string into a date and false if it can't. I've never seen it return
false on an actual date. The only time I saw it return true on a non date was
for the string "apr 31". That was in version 4.5. If you are working version
7, try it. See if it still returns false.
Just so you know, even though we know that you can trick isDate with at least
one string, we have been using it for years and not once has a real person
caused it to return true with a non-date.
Originally posted by: cfKismet
Sorry, I should have been more specific. The page that processes all of my
Coldfusion validation does it free-form as not all of my validation can be
accomplished through masks. Can someone confirm whether or not IsDate actually
works as intended in Coldfusion 7? (i.e. doesn't just validate the format, but
actually if its a real date or not)
Dan Bracuk Guest
-
cfKismet #7
Re: Date Validation
Thanks for the help, guys. I'm using IsDate now, but I still have a problem
with it. Users on my site enter a date in a text field in MM/DD/YYYY format
which then gets entered into a database. The problem is that if they enter
something like 13/05/2005, which according to the formatting I'm looking for is
invalid, IsDate lets it pass through as 05/13/2005. Obviously, IsDate can
convert it to a valid date, but I still need to catch the error somehow. Is
there a way to force it to be interpreted a certain way?
cfKismet Guest
-
Dan Bracuk #8
Re: Date Validation
Yes.
Change your form. Among the ways that will work are:
a. have separate form fields for day, month and year.
b. use a flash form with a datepicker
c. use a javascript popup calendar
Dan Bracuk Guest
-
cfKismet #9
Re: Date Validation
Thanks, Dan. I think I might opt to use seperate date fields, just for ease of
mind. One more question, though. I'm using that same date in a DateCompare
function, so of course when the date isn't formatted correctly, Coldfusion
errors out even before it gets to the IsDate function. I've had this problem
before with variables that might not exist and have been able to use cfparam to
fix that, but I don't know how to get around this.
To summarize, I'm using DateCompare to make sure that the date they supply
isn't later than another date, but if they supply an invalid date, Coldfusion
tries to process it and the page fails before IsDate can even catch it. Any
thoughts?
cfKismet Guest
-
Dan Bracuk #10
Re: Date Validation
Datecompare?? Didn't realize there was such a function. Amazing what you
learn by volunteering to answer questions.
In any event, we have some bread and butter applications where I work. One
type is where the user is presented with a form and asked to submit a start and
end date. If they do it correctly, they find out what happened between those
two dates.
We do this so often that, way back when, I wrote a custom tag (patting myself
on the shoulder) that:
1. Ensures both form fields are valid dates.
2. Ensures the end date is equal to or later than the start date.
3. Ensures both dates co-incide with when data is actually available.
4. Makes sure they are not too far apart.
5. Converts them to yyyy-mm-dd format.
I just temporily changed my profile so that I will accept private messages at
work (where I currently am not). If you ask, I'll send it to you. Ask
quickly, I am isolating myself again tomorrow.
Dan Bracuk Guest
-
cfKismet #11
Re: Date Validation
Hi Dan...just sent you a private message, but I'm not sure what to expect...never used the feature here. I have my own settings set to receive private messages as well
cfKismet Guest



Reply With Quote

