471,852 Members | 815 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,852 software developers and data experts.

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 1018
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 NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.