Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with date...

Status
Not open for further replies.

garfield11

IS-IT--Management
Jul 4, 2002
44
SG
Hi.

I need to create a quotation but I have some problen with the date. I have a text field called QDate and I want it to, as default, display today's date when a user opens a new quotation form. Also, I want to make it so that users can change the date. How to check and ensure date entered is a valid date and in dd:mm:yy format? Finally, when user edit the date, how to check that date entered is not later then today's date?

Thanks!

Love_Garfield =)
 
hi garfield,

For today's date u can always use the system date and display it.

to check the validity of the dates, u cna use the below function,

publish date is the date entered by the user!!!
function validateDateFormat(publishDate)
{
if(publishDate.length > 0)
{

if( (publishDate.charAt(1) == '/') && (publishDate.charAt(3) == '/') || (publishDate.charAt(2) == '/') && (publishDate.charAt(5) == '/') || (publishDate.charAt(2) == '/') && (publishDate.charAt(4) == '/') || (publishDate.charAt(1) == '/') && (publishDate.charAt(4) == '/') )
{
return true;
}else{
alert("Please enter Date as shown in date format");
return false;
}

}
}

To check that the entered date is not later than today's date...
U can write a function which takes in the entered date as a parameter, and inside have a new date object created and take the system date. Convert your text date also to the date object. Then the difference between the two dates can be subtracted out...

hope this helps!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top