Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Javascript Date Validation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

JJenson
Advanced Member

USA
2121 Posts

Posted - 11 November 2008 :  11:54:49  Show Profile  Visit JJenson's Homepage  Reply with Quote
Just wondering if anyone has some javascript code or know where I might find some that will do the following:

Let someone select a date today or in the past but will not allow them to pick any future dates?

I need this for a feedback form and we need to let them put what day into the field but obviously they can't visit int he future and be giving feedback today

Any help would be great I just can't seem to find how to do this variation.<

AnonJr
Moderator

United States
5768 Posts

Posted - 11 November 2008 :  13:06:22  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Have you set up any server-side validation? I ask only because you're still going to want to do that even if you do get the JS working.

All things being equal, I would work on the server validation first, and then add in the JS next. I say that only because its the only way to be sure you get what you want. Some people turn JS off, others may not have the most current browsers (I still have a small number of people that visit the Jesus Joshua site using IE5.5...).<
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 11 November 2008 :  13:53:29  Show Profile  Visit JJenson's Homepage  Reply with Quote
Well the client only wants me to do the Javascript so thats all I am doing but I told them it wouldn't be 100% but they still only want javascript.<
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 11 November 2008 :  16:08:51  Show Profile  Visit AnonJr's Homepage  Reply with Quote
If that's what they ask for, then that's what they ask for. However, it would be prudent to point out the number of people using extensions like NoScript. Not knowing about your client, I also wonder if they really understand or just know that "JavaScript" is one of those things they are supposed to ask for...

As for how to go about doing it, I seem to remember seeing a couple of validation frameworks out there that would simplify things. Its been so long since I last bothered with JS validation I don't recall the names off the top of my head. These days I just do all validation server side. It simplified my testing headaches.<
Go to Top of Page

JJenson
Advanced Member

USA
2121 Posts

Posted - 11 November 2008 :  16:30:16  Show Profile  Visit JJenson's Homepage  Reply with Quote
Yeah I know what you are saying but they are paying me for the JS and don't want to spend any other money. This is a customer that I am not going to just go ahead and do extra for them. But I have defiantly told them to do both but oh well.

Yeah I will keep looking.<
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 11 November 2008 :  17:06:18  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Check over at http://www.codeproject.com/ - I seem to remember seeing a few there. Its been a while since I was last there as they were getting more .NET projects than anything else for a while. Its not that I have a thing against .NET, its just not what I'm doing right now.<
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 11 November 2008 :  19:49:23  Show Profile  Reply with Quote
Why not simply use DateSerial? Convert (today) and the (input date) into "yyyymmdd" format, then use a comparison.


if DateSerial("strinput") > DateSerial("strtoday") then 
	'do nothing, date is in the future
else
	'do whatever it is you wanted done
end if
<
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.1 seconds. Powered By: Snitz Forums 2000 Version 3.4.07