@jcbotero
Posted
Hi mickislim!. Nice code!. If you don't mind I would like to make a suggestion. I think you forgot to include a couple of things :
1.The credit card number field is not separating every 4 digits To add space every 4 digits, in your javascript sheet you can add an eventlistener that takes the id of that input, and through the .replace() method, give an instruction to place a space every 4 digits. This way:
document.getElementById("cardnumber").addEventListener('input', function (e) { e.target.value = e.target.value.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim(); });
2.The image of the credit card is not reflecting the values entered in the fields. For this, you can use javascritp to send the value from one field to the other:
document.getElementById("inputFilled").innerText = document.getElementById("imgInput").value;
This within a function, or within an eventlistener.
If you think this helped you, please mark the comment as helpful. Thank you!