Click here to Skip to main content
15,886,773 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello Guys!

How to show only previous 3 months and 90 days from current date. Here's my code.
C#
Any help? Thanks guys!


What I have tried:

<!doctype html>
<html lang="us">
<head>
<meta charset="utf-8">
<title>jQuery UI Example Page</title>
<link href="jquery-ui.css" rel="stylesheet">
<style>
body{
font: 62.5% "Trebuchet MS", sans-serif;
margin: 50px;
}

</style>
</head>
<body>

Date: <input type="text" id="datepicker">



<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.js"></script>
<script>

$( "#datepicker" ).datepicker({
inline: true,
changeMonth: true,
changeYear: true,
minDate: -20,
maxDate: "+1M +1D"
});

</script>
</body>
</html>
Posted
Updated 31-Jan-20 21:36pm

<pre lang="JavaScript">$(function() {

$( &quot;#datepicker&quot; ).datepicker({
changeYear: true,
minDate: '-3M',
maxDate: new Date(),
});
});</pre>



HTML
<div class="demo">

<p>Date: <input type="text" id="datepicker"></p>

</div>
 
Share this answer
 
Try with below code:

Jquery code
JavaScript
<script type="text/javascript">
	jQuery(function() {		
		var date = new Date();
		var currentMonth = date.getMonth();
		var currentDate = date.getDate();
		var currentYear = date.getFullYear();
		
		$('#calendar123').datepicker({
			minDate: new Date(currentYear, currentMonth-3, currentDate),
			maxDate: new Date(currentYear, currentMonth+3, currentDate)
		});
	});
</script>

HTML code
HTML
<div style="font-weight: bold;">Disable Future Dates</div>
<div id="calendar123"></div>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900