Jquery datepicker仅显示当前日期之前的3个月和90天 [英] Jquery datepicker to show only previous 3 months and 90 days from current date

查看:116
本文介绍了Jquery datepicker仅显示当前日期之前的3个月和90天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys!



如何仅显示当前日期之前的3个月和90天。这是我的代码。

Hello Guys!

How to show only previous 3 months and 90 days from current date. Here's my code.

Any help? Thanks guys!





我尝试了什么:



<!doctype html>

< html lang =us>

< head>

< meta charset =utf-8>

< title> jQuery UI示例页面< / title>

< link href =jquery-ui.css rel =stylesheet>

< style>

body {

字体:62.5%Trebuchet MS,sans-serif;

保证金:50px;

}



< / style>

< / head>

< body>



日期:< input type =textid =datepicker >



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">

推荐答案

(#datepicker)。datepicker({

inline:true,

changeMonth:true,

changeYear:真的,

minDate:-20,

maxDate:+ 1M + 1D

});



< / script>

< / body>

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

</script>
</body>
</html>


请尝试使用以下代码:



Jquery代码

Try with below code:

Jquery code
<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 日期(currentYear,currentMonth-3 ,currentDate),
maxDate: new 日期(currentYear,currentMonth + 3,currentDate)
});
});
< / script>
('#calendar123').datepicker({ minDate: new Date(currentYear, currentMonth-3, currentDate), maxDate: new Date(currentYear, currentMonth+3, currentDate) }); }); </script>



HTML code


HTML code

<div style="font-weight: bold;">Disable Future Dates</div>
<div id="calendar123"></div>


这篇关于Jquery datepicker仅显示当前日期之前的3个月和90天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆