The TextBox control offers a MaxLength property, which allows the insertable text into that TextBox be clientside limited to the specified amount of chars.
My questions:
The maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> .
The maximum number of characters that can be manually entered into the text box. The default is 0, which indicates no limit.
Use the MaxLength property to limit the number of characters that can be entered in the TextBox control.
It does not depend on javascript but that does not make it safe.
Anyone can still post a request using javascript (XmlHttpRequest for example) or just craft a request to send more data than the max-length specification. It's a good way to stop a normal user from over populating a field but it is something you need to double check on the server anyway.
Can I rely on the fact, that the Text property contains no text longer than MaxLength ?
No. Consider it a user-friendliness feature. You will have(as always) re-check on the server. And maybe also check in JavaScript, depending on what its for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With