JS文本框每隔4个数字加一个空格,银行卡号文本框
<input type="text" onkeypress="return (function(key,that){return (key>47&&key<58) && ((that.value.length%5==0)?that.value+=' ':1)})(event.keyCode,this)" />
demo:
致读者:感谢你阅读本文,请随手点击右下角的推荐或分享,谢谢!
<input type="text" onkeypress="return (function(key,that){return (key>47&&key<58) && ((that.value.length%5==0)?that.value+=' ':1)})(event.keyCode,this)" />
demo: