Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Date Validations Using Dropdownlist

Posted on 2011-09-29
3
Medium Priority
?
210 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
[X]
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
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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

662 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