项目爬坑路

2017-06-28  本文已影响0人  牛奶是本命___
记录下自己项目中遇到的坑点,边做边总结吧
  1. 判断变量是否为空及变量为0的情况
Paste_Image.png

如果你的变量为0千万要注意下

2.时间串截取改格式

beginTimes = beginTime.substring(0,4)+'-'+beginTime.substring(4,6)+'-'+beginTime.substring(6,8)+' '+beginTime.substring(8,10)+':'+beginTime.substring(10,12);

3.js移除空格,回车

var resultStr = testStr.replace(/\ +/g, ""); //去掉空格 resultStr = testStr.replace(/[ ]/g, ""); //去掉空格 resultStr = testStr.replace(/[\r\n]/g, ""); //去掉回车换行

4 限制文本框只能输入数字
onkeyup="this.value=this.value.replace(/[^\d]/g,'') " //防止从别处粘贴 onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"

上一篇 下一篇

猜你喜欢

热点阅读