Restrictive Date Field In Javascript Or Php

liunx

Guest
Hey guys, I need to know if anyone knows how to make a restrictive date form field in either PHP or JavaScript?<br /><br />I want people to be able to pay invoices online, but I am only accepting the payment for an invoice date of 45 days or less from the date of invoice. So if they received an invoice from November 1st, and they went to pay it today online, the 13th, the form would be accepted since it's less than 45 days. But if they went to pay it two months from now, they would fill in the invoice date, and a message would pop up saying invoice cannot be paid online.<br /><br />Does anyone know how to go about doing this?<br /><br />Thanks!!!<!--content-->
I'm not sure how to do it in JS...<br /><br />With PHP, I would basically set it up so that the invoice date gets converted using strtotime(). This will convert it to the same system PHP uses for its time() function.<br /><br />Once the invoice date is converted using strtotime(), do a comparison like so"<br /><br />if(($Converted_Invoice_Date + 3888000) < time())<br />{<br />// output error message here, so whatever you need to do<br />}<br /><br />3888000 is the number of seconds that pass in 45 days, and by adding that to the invoice date, if it has been longer than 45 days, it will be less tahn the current time.<br /><br />Someone else may be able to explain it clearer.<!--content-->
Well, that worked! Thanks!<!--content-->
Cool, you're welcome! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /><!--content-->
 
Back
Top