Why is a credit card number using type text?

Why does the type attribute have a value of “text” instead of “number”. We are dealing with a credit card number no?

<input id=“payment” name=“payment” type=“text” required pattern="[0-9]{14,16}">

Which lesson is this on?

If it were type number then we couldn’t apply a regex pattern, might be one explanation.

1 Like

Validation - Matching a Pattern

Instead of the regex [0-9], I think giving a “number” value to the type attribute makes more sense and it’s not complex.

But like @mtf said, you can’t apple patterns to a input type number. Try it.

You are arguing for something that you think is better. One thinks that if this lesson was to be understood and followed, it would be best to not argue for or against anything. Read the lesson. Learn what it applies, how and why. The lesson is about patterns, which are strings. No argument can change that.

If one intends for literal number inputs, then validation will involve knowing the upper and lower bounds.