看了网上有很多的解决方法,我也写一个比较简单方法。实现easyui的datebox格式化。效果如下,用“++”隔开,看你喜欢用什么都可以。
1、html
<span class="span1">证件有效期至:</span> <span><input id="passvali" name="hotel.passvali"></span>
2、js
/* 证件有效期至 */ $('#passvali').datebox({ formatter: function(date){ var years=date.getFullYear();//获取年 var months=date.getMonth()+1;//获取日 var dates=date.getDate();//获取月 if(months<10){//当月份不满10的时候前面补0,例如09 months='0'+months; } if(dates<10){//当日期不满10的时候前面补0,例如09 dates='0'+dates; } return years+"++"+months+"++"+dates;//根据自己需求进行改动 } });
补充:
DateBox 日期显示默认的格式为“dd/mm/yyyy”,如果想自定义成我们的格式需要实现两个函数,formatter和parser。
formatter函数使得选择日期后将其格式化为我们需要的格式,parser函数在选择好日期后告诉控件如何去解析我们自定义的格式。
定义如下:
formatter:A function to format the date, the function take a 'date' parameter and return a string value.
parser:A function to parse a date string, the function take a 'date' string and return a date value.
如将日期格式化为yyyy-mm-dd的格式:
$('#dd1').datebox({ formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();}, parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));} });
以上就是为大家分享的easyui的datebox格式化最简单方法,希望对大家的学习有所帮助。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 群星.2022-传家电视剧原声带【东阳欢娱】【FLAC分轨】
- 《摇滚教父 伍佰黄金精选 2CD》 [WAV+CUE][1GB]
- 《凤凰传奇 我从草原来》[WAV/分轨][400MB]
- 《叶倩文 真心真意过一生》[WAV+CUE][400MB]
- 潘越云.1985-世间女子(滚石25周年经典复刻版)【滚石】【WAV+CUE】
- 陈柏宇.2009-CANT.BE.HALF【SONY】【WAV+CUE】
- 李明依.1989-小女生【滚石】【WAV+CUE】
- 《李荣浩 新时代创作新人王》[WAV分轨][310MB]
- 《黑鸭子与马头琴 史上最动听草原音乐》[WAV+CUE][320MB]
- 《汽车发烧音乐精选CD18》[FLAC+CUE][7.1G]
- 郑希怡.2004-Perfect.Date【英皇娱乐】【FLAC分轨】
- 群星.1994-宝丽金超级孖宝2CD【宝丽金】【WAV+CUE】
- 林忆莲.2019-0(2023精装版)【环球】【WAV+CUE】
- Supper.Moment.2016-The.Moment【寰亚】【FLAC分轨】
- 范莉丝.1979-送郎一朵牵牛花(LP版)【大联机构】【WAV+CUE】