...

View Full Version : Hide Submit on Date Select in Past



mustangkid
06-23-2012, 08:05 PM
Hey guys I need some assistance in developing a code that will hide the submit button of a form if a date in the past is selected. The variable for the date box is firstleveldate and the date appears in a MM-DD-YYYY format.

Thanks!

WolfShade
06-24-2012, 12:00 AM
Load the form with the submit button disabled, then place an onBlur event in the firstleveldate field that checks the date value. If it's before the current date, do nothing; if it's AFTER the current date (or is the current date?), then document.forms["formName"].submitButtonName.disabled = false;

Lerura
06-24-2012, 12:57 AM
you can use this:
function TestDate(Input, CurDateValid){
var seg=Input.split('-');
var Dato=new Date(seg[2],seg[0]-1,seg[1]);
var Now=new Date();
var NowReset=new Date(Now.getFullYear(),Now.getMonth(),Now.getDate());
return ((CurDateValid?NowReset:Now)<=Dato);
}
to test if the date is valid.

If today is a valid date then

if (TestDate(firstleveldate,1)){
--show/enable button--
}else{
--hide/disable button--
}

if not:
if (TestDate(firstleveldate,0)){ // or: if (TestDate(firstleveldate)){
--show/enable button--
}else{
--hide/disable button--
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum