James
James

Reputation: 576

Can I style individual characters in an input?

A client has asked to use the type="number" attribute for a credit card field in order to get the right keyboard on mobile devices, but would like some padding after every 4th character to make it look more like a credit card number. Is such a thing even possible?

Upvotes: 0

Views: 246

Answers (2)

Raj
Raj

Reputation: 121

mask input plugin is the best option for that.

$('#creditcard').mask('0000 0000 0000 0000');

Upvotes: 2

Ronen Cypis
Ronen Cypis

Reputation: 21470

You can use different separate inputs, all of type 'number', and move focus between them using javascript every time the input meets your criteria (let's say: 4 characters...)

Upvotes: 0

Related Questions