473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how can we implement the date validation by javascript in drop-down box

hi sir,

I have following code:

{code}

[HTML]<html>
<body>
Name:<input type="text" name="n1" id="n1">
DOB: <select name="dd"><option value="date">date</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select name="mm"><option value="month">month</option>
<option value="jan">jan</option>
<option value="feb">feb</option>
<option value="mar">mar</option>
</select>
<select name="yyyy"><option value="year">year</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
</select>

</body>
</html>[/HTML]


I wanna put the validation in date, month and year for passing the message " future date not allowed" when user select the future date,month year respectivily. How can get element value of the dropdown listbox from html page
for comparing the value from curnnt date function through java script in saparet javascript file.

Thank you.
Jul 22 '08 #1
4 4326
r035198x
13,262 8TB
Give the dropdown an Id and use document.getElementByID.
There's a lot of examples all over the internet for this.
Jul 22 '08 #2
hi sir,

1.
<html>
2.
<body>
3.
Name:<input type="text" name="n1" id="n1">
4.
DOB: <select name="dd" id="dd"><option value="date">date</option>
5.
<option value="1">1</option>
6.
<option value="2">2</option>
7.
<option value="3">3</option>
8.
</select>
9.
<select name="mm" id="mm"><option value="month">month</option>
10.
<option value="jan">jan</option>
11.
<option value="feb">feb</option>
12.
<option value="mar">mar</option>
13.
</select>
14.
<select name="yyyy" id="yyyy"><option value="year">year</option>
15.
<option value="2007">2007</option>
16.
<option value="2008">2008</option>
17.
<option value="2009">2009</option>
18.
</select>
19.

20.
</body>
21.
</html>


javascript code goes here:
{code}
function date_validation()
{
var userDate=getElementbyId.....//i havn't idea how can get userdate after user selection
var today = new Date();

if (userDate <= today)
{
alert("future date not allowed");
}
else
{
//alert("uture date allowed");
}
}

how can implement this java script code and please help about helpfull code.

thank you.
Jul 22 '08 #3
r035198x
13,262 8TB
Perhaps a Javascript tutorial is not a bad thing to read at this point?
Jul 22 '08 #4
gits
5,390 Expert Mod 4TB
please read the posting guideline carefully again ... don't post such a code-mess with line-numbers inline text or whatever, use code-tags, try to explain your problem in more detail and the best would be an example for what you want to achieve, don't multipost questions etc. ... you got a warning already and i don't want to ban you right now ... but be aware that further behaviour in such a way will result at least in a temporary ban ... FOLLOW THE GUIDELINES! ... this is the last friendly warning ...

regards
MOD
Jul 22 '08 #5

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

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
14
by: Steve Wright | last post by:
I am trying to validate if an entry on a form is a date. I have adapted code I found here http://www.codingforums.com/archive/index.php/t-14325 as below but I can't seem the get the results that I...
4
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
6
by: MickG | last post by:
Hi, I am trying to validate these values, this seems to work fine for the phone number and name but I am trying to get the program to fail to submit and set the focus on the date when 2006 is...
23
by: Ash | last post by:
Hi everyone, This problem has been puzzling me for a fair time now, and has severely frustrated me!! Perhaps I'm just not getting the syntax right, but the problem is rather simple... Take a...
3
by: pmarisole | last post by:
The following javascript code gives me the date validation that I need except after the correct date is entered into the field, it puts the date in the wrong format EXAMPLE: User enters...
1
by: joeyej | last post by:
I'm using this code to make sure users are unable to choose a date from a drop list (<option value="June 8, 2006, (Thursday), 9am">June 12, 2006, (Thursday), 9am) that is less than two days out...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
5
by: Peter Afonin | last post by:
Hello, I'm not an expert in Javascript, so I'm seeking an advice. As I mentioned in my previous post, I use Javascript to check whether at least one checkbox in the datagrid has been checked....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.