Pregunta

I am learning jQuery and PHP to create my own form validation. I have read several tutorials but I do not see any consideration or notation in regards to capping the maximum length? I did see minimum length requirement suggestions but I wanted to know if this was a best practice to limit the maximum allowed characters.

Does this sound good?

  • Email address = 25 characters
  • Name = 20 characters
  • Message = 200 characters with a notation that there is a max.
¿Fue útil?

Solución

RFC 3696 says that the maximum total length for an email address is 320 characters ("local part": 64 + "@" symbol: 1 + "domain part": 255 = 320). It's very rare that you'll encounter an address this long, but you should support them nevertheless.

Source: https://www.rfc-editor.org/rfc/rfc3696 (section 3: Restrictions on email addresses, last paragraph)

Otros consejos

I've already seen longer email adresses... People have email adresses with a full name (which already can be already equal to ±25 chars) and then @domain.

I'd set the limit for email adresses to at least 40-50 characters.

and the name then to ~30 characters. (If you want only first and family name, when you want the full name, set it to at least 50 characters.)

The message length is really not much, alone the text I'm just writing you to explain why your limits are too low is longer. If such a low limit is not absolutely needed, then make for example 1000 characters (or 65535 for a full TEXT column in the database), but indicate the limit - and best the actual count too.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top