JavaScript日期控件

今天向大家介绍 Swazz Javascript Calendar这个脚本日期控件。官方网址提供了使用方法和源代码下载. 官方网址
  演示效果图:

 
 
 现在简单介绍使用方法:
 

Step 1
Include the folllowing somewhere in the HTML of your page

  < SCRIPT SRC = " calendar.js " ></ SCRIPT >

NB: Make sure "src" points to the correct location of the calendar.js file

Step 2
Find the input text box you would like the calendar to appear on. Modify it to include the following

< input type = " text "  value = " dd/mm/yy "  onfocus = " this.select();lcs(this) "  onclick = " event.cancelBubble=true;this.select();lcs(this) " >   

 

英文很简单不需要翻译了吧。

但是你在测试的时候会发现,它只显示当前那个月以后的日历。不能显示这以前的日历,当然着也时候某些日期的使用,比如需要当天的时间,比如客房预订,肯定是当天以后的事情。但是如果是要填写生日的话,估计就需要几年前甚至几十年前的日子了。修改方法如下:

找到calendar.js中如下的代码:

    1 //  Calendar script  
   
2 .   
   
3 . var  now   =   new   Date ;  
   
4 . var sccm = now .getMonth();  
   
5 . var sccy = now .getFullYear();  
   
6 . sccy  =  sccy - 2 ; // 修改这里,几年前就减去几  
   
7 . var ccm = now .getMonth();  
   
8 . var ccy = now .getFullYear();  

 

正如代码中所描述的,假如你需要2两年前的当前月开始计算,那么就把sccy-2. 依此类推。很简单吧。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值