当不足3位时前面加0(客户端实现方法)
参考资料:http://www.thescripts.com/forum/thread148223.html
<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)">
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