Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Date Validations Using Dropdownlist

Posted on 2011-09-29
3
204 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
ID: 36883485
How about adding jquery validation to dropdownlists?
0
 
LVL 3

Expert Comment

by:exceter
ID: 36888784
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
ID: 36890755
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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