Hey all. In Joomla! I need to set up a contact form to have a 48 hour buffer. In other words I don't want users to be able to submit a contact form unless it is 48 hours before a date selected from a drop down menu.
If someone has had experience with the case I explained and could point me in th开发者_Go百科e correct direction that would be great.
Cheers.
Essentially, you are doing form validation. You need to trigger some javascript when the form is submitted, then calculate the time difference between now and the selected date. Hard to give exact code without seeing what you have, but I can give you the basics -
In the form -
<form action="your_submit_url.php" onSubmit="return TestDate()">
The javascript -
function TestDate()
{
today=new Date()
selectdate = Form.elements["yourdate"].value;
if ((Math.ceil((today.getTime()-selectdate.getTime())/(86400000)) >= 2) {
return true;
}
else
{
alert('Some warning about 2 days');
return false;
}
Obviously you will need to make adjustments to match your form, but this is the basic idea. Also, I didn't test the javascript at all, knowing me it will need to be tuned up as well.
精彩评论