Open stanleynik opened 3 years ago
There is nothing built in so you will have to code this yourself in Javascript
To remove whitespaces from a card number input in a programming language like JavaScript, we can use the replace function to replace all whitespace characters with an empty string.
Example : // Assuming cardNumber is the input containing whitespace let cardNo = "1234 5678 9012 3456";
// Remove whitespaces let cleanedCardNo = cardNumber.replace(/\s/g, '');
console.log(cleanedCardNo);
In this example, the regular expression \s matches any whitespace character, and the g flag ensures a global search, replacing all occurrences. The result is a card number without any whitespaces.
But I would like to keep the whitespaces in the card