如何在html输入的四个字符后插入空格? [英] How to insert space after four characters in html input?

查看:51
本文介绍了如何在html输入的四个字符后插入空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户使用JavaScript输入信用卡号时,我需要在每四个字符后插入一个空格.

I need to insert a space after every four characters while the user is typing a credit card number using JavaScript .

<input type="text" size="19" maxlength="19" data-stripe="number" placeholder="1234 5678 9012 3456">

完成此任务的最佳方法是什么?

What is the best way to accomplish this ?

推荐答案

您可以使用jquery和mask进行检查,请检查它 jquery and mask 对于jQuery,您只需要戴上面具

you can use a jquery and mask for it please check it jquery and mask for jquery you only need put a mask

$("#date").mask("9999 9999 9999 9999");

选中它

这篇关于如何在html输入的四个字符后插入空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆