soniya soniya soniya soniya - 1 month ago 9
HTML Question

How to insert space after four characters in html input?

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 ?

Answer

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");

check it