Hi,
I am working on Java web application.
In the initila webpage of my application,
there is a text box to enter a Date (dd.MM.yyyyy format).
My requirement is to check the entered date should not be greater than today’s date.(when submitting this page by clicking on submit button.)
Could you please explain how to handle this validation in Javascript?
Thanks in Advance.
Abdul Gafar
Java is to JavaScript as ham is to hamster.
Java !== JavaScript
Ham !== Hamster
Hampton the hamster is not a pig, and JavaScript is not a part of Java. Get it?
Anyway, onwards.
The date documentation is what you need.
Create a date and set the day, [url=“https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/setMonth”]month and [url=“https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/setFullYear”]year to those from your form.
Warning: months are set from 0 to 11
Use a second date for todays date, and use getTime to compare the two.
Hi Paul,
Thanks for your inputs.
I think, You know that,
The web applications, which are developed in Java/J2ee, or microsoft . net technology; the Javascript is used for validation.
Thank god for that, we don’t see too much of Java around these parts so please forgive my tired reply.
Paul,
The date documentation, which you mentioned is useful for validating my requirement.
Many Thanks,
Abdul Gafar