Reputation: 29
I want to have a textbox that whenever you reached the 4th digit it would add a space automatically and it should do that everytime the 4th digit is inserted.
Ex. 4565 6585 6599 5656 ...
I have tried something like this but most likely it is wrong:
textBox2.Text.ToString(new NumberFormatInfo() { NumberGroupSizes = new[] { 4 }, NumberGroupSeparator = " " });
Any ideas?
Upvotes: 0
Views: 154
Reputation: 460238
You could use a MaskedTextBox
control with a mask like this:
txt.Mask = "0000 0000 0000 0000";
Here is a summary of the syntax.
Upvotes: 3
Reputation: 2133
You can do this using JavaScript or jQuery.
Please look at this SO entry on "Credit Card Input Form Using jQuery".
Upvotes: 0