Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Date Validation (Preventing future dates)

Participant ,
Nov 07, 2007 Nov 07, 2007
Hello,
How do you validate on future dates. I have a form where I don't want things entered ahead of today's date. Anyone have a validation that does this?

Thanks!
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 07, 2007 Nov 07, 2007
On the server it's easy, compare it to cold fusion's now() function.

On the client it's a bit more complicated because you have to use javascript.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 07, 2007 Nov 07, 2007
Or you could use DatePart. Once the data is submitted check to see if the day is greater than today, if it is send them back to the form.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2007 Nov 08, 2007
LATEST
create javascript date obj that store today date
convert date from from to javascript date obj as well
then you can simple use > or < to check form date is in the future or not.

var today = new Date();
var a = new Date(year,month,day);
if (a > today) alert("no future date is allowed");

hope that can help.

Tiono
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources