Guest User

Untitled

a guest
Nov 25th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. //Since JavaScripts counts months starting from 0 (January is 0),
  2. //subtract 1 from the month integer submitted by the user
  3.  
  4. var formattedMonth = userSubmittedMonth - 1;
  5. var testDate = new Date( userSubmittedYear,formattedMonth,userSubmittedDay,0,0,0,0) ;
  6.  
  7. if (
  8. testDate.getFullYear() != userSubmittedYear
  9. || testDate.getMonth() != formattedMonth
  10. || testDate.getDate() != userSubmittedDay
  11. )
  12. {
  13. alert( "The date that you entered doesn't exist (like Feb. 31)" );
  14. }
Add Comment
Please, Sign In to add comment