怎样判断输入的日期是不是一个月的? 有开始年月日文本框,终止年月日文本框,输入日期后,怎样判断,输入的日期是不是一个月的?就是说,假如输入 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('不是同一个月'); } 关于一个DOM节点的插入? 對TEXTAREA的添加內容的JS功能代碼 jquery如何load gb2312的页面~~~ 急急急 跪求有关IE、FireFox、Safari 这3个浏览器的javascript的兼容问题,希望大家多多帮助! 如何获取地址栏参数? 请教一个简单的javascript全局变量问题 一个关于 setTimeOut 的问题,, 两个框架之间链接跳转问题![精典问题!] 表单中内容替换! JS方法的定义后面跟有一个参数??? 用过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('不是同一个月');
}