Hacker News new | ask | show | jobs
by eviks 336 days ago
Demo form's phone number field accepts text, so no validation?
2 comments

> Demo form's phone number field accepts text, so no validation?

It validates email, though.

How would you validate phone numbers? Surely phone numbers must allow spaces as well. Maybe allow '+27' too? Quite a lot of exceptions come to mind for phone numbers.

What if someone wants to type in a phone such as `123 456 7891 ext 21`?

What if they want to use `0800 SAVE MUNNY`? That's the number `728 368 669`.

What if they want to enter `123 456 7891 oh/123 789 4561 ah`?

> Quite a lot of exceptions come to mind for phone numbers.

That's why proper form building isn't just slapping some style over a text field. You'll have to parse it anyway, so better not delay and risk accepting errors that the user could correct right away

The classic phone number to allow through validation is “PLEASE DON'T CALL ME I'M DEAF”.
You can still read 2fa codes...
If you’re sending 2fa over sms then you’ve got bigger problems.
No, not universally. But also, it's not the form's role to block on those problems.
I didn't add any validation that's why it might be accepting text
> I didn't add any validation that's why it might be accepting text

See my directly reply above your reply.