![]() ![]() Set it to 4-6-5 for Amex and default to 4-4-4-4 for all other cards. Create a variable called partitions to handle the spacing format.Here's how I did it inside the payment component in my app: (Put this code in a directive if you have multiple credit card inputs in your application.) You can write a custom component or directive for this, but no need to do so if you only have one component in your application that is taking credit card numbers, which is often the case. If we don't handle this, the loop will make editing the number a weird UX headache. The only tricky part is handling Backspace and Cursor Position editing (ie if the user clicks inside the input to edit it). We can just loop through the numbers and add a space every four digits for most Credit Card types, but in a 4-6-5 pattern for American Express. This works in Angular 7+ and probably earlier versions too. Loop through the credit card number and manually add spaces ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |