Solved

Date Validations Using Dropdownlist

Posted on 2011-09-29
3
203 Views
Last Modified: 2012-05-12
Hi,
I am Developing A Form ,In that Form I am using three dropdown lists respectively they are drdDay,drdMonth,drdyear. The drdDate  contains 1-31 days and drdMonth contains 1-12 and drdyear Contains Previous year and Present year. Now I Validating allow to select only 10 days less than the Present/Current date. If any one select more than the Present/Current date and select lessthan 10 days raise an Error.I am Really confusing  to handle this Any one Help me to Over come this Problem and  i don't want to use ajax calender control. If any Other alternative than the Ajax Calender Control and Dropdown list please suggest me. Thank You.
0
Comment
Question by:CPSRI
3 Comments
 
LVL 17

Expert Comment

by:sonawanekiran
Comment Utility
How about adding jquery validation to dropdownlists?
0
 
LVL 3

Expert Comment

by:exceter
Comment Utility
What error do you have?
could you paste here that part of your code ...
0
 
LVL 9

Accepted Solution

by:
richard_hughes earned 500 total points
Comment Utility
Hello CPSRI

This code will produce an error is the date selected is either 10 days before or 10 days after today.

NOTE: if you are unfamiliar with jQuery or are unsure where to download it, you can get it officially here for free: http://jqueryui.com/download

Thanks,

Richard Hughes
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Date Example</title>
		<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" rel="stylesheet" />	
		<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
		<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
		<script type="text/javascript">

			$(document).ready(function () {

				$("#textDate").datepicker({

					onSelect: function (dateText, i) {

						var date = $(this).datepicker("getDate");

						var today = new Date();

						var difference = today - date;

						var days = (((difference / 1000) / 60) / 60) / 24;

						if (days < -10 || days > 10) {

							// put your error code here
							alert("The date you entered is out of range.");
						}
					}
				});
			});

		</script>	
	</head>
	<body>

		<p><label for="textDate">Date: </label><input type="text" id="textDate" /></p>

	</body>
</html>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now