我如何使用Java脚本禁用未来日期 [英] How I Disable Future Dates Using Java Script

查看:50
本文介绍了我如何使用Java脚本禁用未来日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用java脚本禁用未来日期....谷歌搜索但没有运气....感谢inadvance。

How i disable future dates using java script....have googled but no luck....thanks inadvance.

推荐答案

function CheckEnteredDate(pass){

var arrShortMonths = [JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT ,NOV,DEC];

//拆分输入日期

var date1 = passed.value.split( - );

//替换Date1 [1]月值Ex:'Dec',11,即1小于12,并将selDate设置为用户输入日期

// date1 [1] = arrShortMonths .indexOf(date1 [1]);

if(date1!=''){

date1 [1] = getMonthval(date1 [1]);

var selDate = new Date(date1 [2],date1 [1],date1 [0]);

if(selDate!=''&& selDate> new Date() ){

警报('日期大于今日日期');

}

}

}
function CheckEnteredDate(passed) {
var arrShortMonths = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
//split the input date
var date1 = passed.value.split("-");
//replace Date1[1] month value Ex: 'Dec' with 11 i.e. 1 less than 12 and set the selDate with user input date
//date1[1] = arrShortMonths.indexOf(date1[1]);
if (date1 != '') {
date1[1] = getMonthval(date1[1]);
var selDate = new Date(date1[2], date1[1], date1[0]);
if (selDate != '' && selDate > new Date()) {
alert('Date greater than Todays Date');
}
}
}


您好,



参考:

Hi,

Ref:
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>



Javascript:


Javascript:

<script type="text/javascript">


function (){
var date = new 日期();
var currentMonth = date.getMonth();
var currentDate = date.getDate();
var currentYear = date.getFullYear();
(function() { var date = new Date(); var currentMonth = date.getMonth(); var currentDate = date.getDate(); var currentYear = date.getFullYear();


这篇关于我如何使用Java脚本禁用未来日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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