i have a select type options in which we can select month and year options.
if we select future month and year, it shows error message and clear the select type options.
i have made a script as show below: buit its not working properly.
script:
function dropdown_validator()
{
// Variables for the current date, year and month
var right_now=new Date();
var the_year=right_now.getYear();
var the_month=right_now.getMonth();
// Check to see if the request is within the current year and month
if (payment_voucher.year.value == the_year && payment_voucher.month.value > the_month)
{
alert("Please check the month of your request.");
return true;
}
// Check to see if the year request is calid
if (payment_voucher.year.value > the_year)
{
alert("Please check the year of your request.");
return(false);
}
// Comment out the alert below and change the location to your destination
//alert("The request is valid\nMonth = "+ payment_voucher.month.value +"\nYear = "+ payment_voucher.year.value);
// window.location.replace= dropdown_form.u_month.value + dropdown_form.u_year.value
return(true);
}
form:
<form name="payment_voucher" ACTION="" METHOD="POST" >
<center>Current Processing Month:<select size="1" name="month" onblur="return dropdown_validator()" >
<option value="">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
<option value="4">Apr</option>
<option value="5">May</option>
<option value="6">Jun</option>
<option value="7">Jul</option>
<option value="8">Aug</option>
<option value="9">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>
<select size="1" name="year" onblur="return dropdown_validator()">
<option value="">Year</option>
<option value=2010>2010</option>
<option value=2009>2009</option>
<option value=2008>2008</option>
<option value=2007>2007</option>
<option value=2006>2006</option>
<option value=2005>2005</option>
<option value=2004>2004</option>
<option value=2003>2003</option>
<option value=2002>2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
</select><br><br></center>
plz help me
abhijit


Reply With Quote
Bookmarks