怎样判断输入的日期是不是一个月的? 有开始年月日文本框,终止年月日文本框,输入日期后,怎样判断,输入的日期是不是一个月的?就是说,假如输入 2009年1月1日---2009年4月1日一共三个月就不行,就是说要判断输入的这个日期范围是不是一个月,怎么判断啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var startDate = '2009年1月1日', endDate = '2009年4月1日';startDate = startDate.substr(0,startDate.length - 2).replace(/[^0-9]/g, '/');endDate = endDate.substr(0,endDate.length - 2).replace(/[^0-9]/g, '/');var d1 = new Date(startDate), d2 = new Date(endDate);if(!(d1.getFullYear() == d2.getFullYear() && d1.getMonth() == d2.getMonth())) { alert('不是同一个月');} 这样的情况只能两日期比较了。http://http://www.haixiait.com/article.asp?id=5 一点小错误,重来: var startDate = '2009年1月1日', endDate = '2009年1月1日'; startDate = startDate.substr(0, startDate.length - 1).replace(/[^0-9]/g, '/'); endDate = endDate.substr(0, endDate.length - 1).replace(/[^0-9]/g, '/'); var d1 = new Date(startDate), d2 = new Date(endDate); if (!(d1.getFullYear() == d2.getFullYear() && d1.getMonth() == d2.getMonth())) { alert('不是同一个月'); } 求一验证正浮点数的正则表达式 如何将html中JavaScript中某一变量的值传递到下一个js文件中 JS能不能读取文件的内容?? Jscript问题,请高手指点,最好给出代码 window.open的参数问题 LigerUI表格插件的问题 用了很多方法都无法解密这个encode加密过的脚本..向大家请教! 层与数据库查询 如何让web页面重新刷新一下啊? 就好比F5的作用一样啊 vue项目之配置本地,测试,生产环境,配置axios.defaults.baseURL,解决跨域问题 用过thickbox的高手来指点一下 一个循环查询网页控件的value问题
var startDate = '2009年1月1日', endDate = '2009年4月1日';
startDate = startDate.substr(0,startDate.length - 2).replace(/[^0-9]/g, '/');
endDate = endDate.substr(0,endDate.length - 2).replace(/[^0-9]/g, '/');
var d1 = new Date(startDate), d2 = new Date(endDate);
if(!(d1.getFullYear() == d2.getFullYear() && d1.getMonth() == d2.getMonth())) {
alert('不是同一个月');
}
http://http://www.haixiait.com/article.asp?id=5
var startDate = '2009年1月1日', endDate = '2009年1月1日';
startDate = startDate.substr(0, startDate.length - 1).replace(/[^0-9]/g, '/');
endDate = endDate.substr(0, endDate.length - 1).replace(/[^0-9]/g, '/');
var d1 = new Date(startDate), d2 = new Date(endDate);
if (!(d1.getFullYear() == d2.getFullYear() && d1.getMonth() == d2.getMonth())) {
alert('不是同一个月');
}