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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I NEED A SCRIPT THAT, AFTER A DATE... IT DISSABLES A FORM BUTTON.

Status
Not open for further replies.

seba070707

Programmer
Joined
Aug 6, 2001
Messages
13
Location
AR
Hello from Argentina!

I need an script that can disable a "SEND FORM" button after a date and hour.
Example: I want to receive forms from my web visitors before: "September 10th, 2001 10:00PM". And AFTER that moment the button is disabled by a script or function. Of course, the date and time is taken from the PC that loads the form. If the visitor's PC doesn't have the correct/right date and time and it makes the script not work ... doesn't matter!

I think that it's not very difficult what I'm asking.

Any help would be greatly appreciated. THANKS !!!!
 
You can simply not to display the submit icon if the time difference is equal to or less than zero.

var now = new Date();
// set this value to the countdown date.
var then = new Date("September 2 , 2001");
var gap = then.getTime() - now.getTime();
gap = Math.floor(gap / (1000 * 60 * 60 * 24));
if (gap>0) {
document.write(&quot;<input type=submit value=submit>&quot;);
} else {
document.write(&quot;You're unable to post stuffs now....&quot;);
}

This is the logic of date requirement only and I let you apply it to your page and include the time requirement.

Regards
 
You could also use a function to hide or display the button depending on the date. This is similar to the suggestion made by technicalAnalysis.

<HTML>
<HEAD>
<SCRIPT>
function checkDate()
{
var now = new Date();
// set this value to the countdown date.
var then = new Date(&quot;September 2 , 2001&quot;);
var gap = then.getTime() - now.getTime();
gap = Math.floor(gap / (1000 * 60 * 60 * 24));
if (gap<=0) document.myForm.Submit.style.display = &quot;none&quot;;
}
</SCRIPT>
</HEAD>
<BODY onLoad=&quot;checkdate();&quot;>
<FORM NAME=&quot;myForm&quot;....>
.
.
.
<INPUT TYPE=&quot;Submit&quot; Name=&quot;Submit&quot; Value=&quot;SEND FORM&quot;>
</FORM>
</BODY>
</HTML> Mise Le Meas,

Mighty :-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top