惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
I
InfoQ
博客园_首页
G
Google Developers Blog
爱范儿
爱范儿
Last Week in AI
Last Week in AI
量子位
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
月光博客
月光博客
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - 神话

C#的float型,竟然与SQL中float型不对应(转载) 【源码】非常有用的Vml图像画板(收藏) 为Html 的Select 加一个提示语和输入方法(转载) asp.net三色交替的下拉列表框(转载) 常用正则表达式(收藏) ListBox控件上移、下移操作(Ajax) 获取某行的字段ID值(GridView模板列) 日历控件收藏 我的博客地图脚本代码 实时统计输入字符数 我的博客地图特效 生成html页面 初次使用ZedGraph 梅花雪日历控件(网络收藏) 树型菜单<仿QQ型菜单>(网络收藏) 面向对象分析(网络收藏) 常用正则表达式(收集)及使用方法 三层架构(非原创) 网页常用代码小技巧五(网络收藏)
客户端实现PadLeft
神话 · 2007-06-19 · via 博客园 - 神话

当不足3位时前面加0(客户端实现方法)

<script type="text/javascript">
function padLeft(str, pad, count) {
while(str.length<count)
str
=pad+str;
return str;
}


function check(el) {
el.value
=padLeft(el.value.replace(/^(\d\d)$/,"$1"), "0"3);
}

</script>

<input type="text" onblur="check(this)">

参考资料:http://www.thescripts.com/forum/thread148223.html