469,331 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

Date validation

hi everybody,]
i am using 3 combo boxes for dates.i want date validation in the combo boxes. Eg. no one can select 30 feb and 31 april.

can anybody help me in providing the exact code.

thanx in advance
Aug 6 '07 #1
1 995
692 Expert 512MB

You can write the javascript function for date validation.

<script language ="javascript">

function validate_Date()
var mon;
var mydate;
var ind;

//get selected month
ind = document.getElementById("selMonth").selectedIndex;
mon = document.getElementById("selMonth").options[ind].value;

//get selected date

ind = document.getElementById("selDate").selectedIndex;
mydate = document.getElementById("selDate").options[ind].value;

//check for invalid dates

if (mon == "Feb" && mydate == "31")



<SELECT id="selMonth" name=select1>
<OPTION selected>Jan</OPTION>
<OPTION value ="Feb">Feb</OPTION>
<SELECT id="selDate name=select2>
<OPTION selected value ="1">1</OPTION>
<OPTION value ="2">2</OPTION>
Aug 6 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

30 posts views Thread by Dr John Stockton | last post: by
reply views Thread by Brian Conway | last post: by
7 posts views Thread by Paul | last post: by
12 posts views Thread by Diego | last post: by
1 post views Thread by Brendan Reynolds | last post: by
3 posts views Thread by =?Utf-8?B?Q2hyaXM=?= | last post: by
2 posts views Thread by John Smith | last post: by
5 posts views Thread by Stang02GT | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.