469,646 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Checking Date no earlier than the 1st day of previous month

Hello - Ive been struggling with a javascript date validator to check that the date is no earlier than the first day of the previous month. Can someone help?

Dec 5 '07 #1
1 2231
428 256MB
Create a temporary limiting Date object-
Expand|Select|Wrap|Line Numbers
  1. var D=new Date();
  3. var M= D.getMonth();
  4. if(M== 0) D= new Date(D.getFullYear-1,11,1)
  5. else D= new Date(D.setMonth(M-1,1));
Then you can return (DatefromInput > D);
if it is false, the Date you are testing is earlier than the first of the month.

This assumes you have made a Date object from the date input.
Dec 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Jim | last post: by
7 posts views Thread by Drygast | last post: by
3 posts views Thread by Bob Sanderson | last post: by
16 posts views Thread by W. eWatson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.