Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Date Validations Using Dropdownlist

Posted on 2011-09-29
3
Medium Priority
?
212 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

824 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