TextBox-Control 的 MaxLength 属性有多可靠? [英] How reliable is the MaxLength property of the TextBox-Control?

查看:19
本文介绍了TextBox-Control 的 MaxLength 属性有多可靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TextBox 控件提供 MaxLength 属性,允许在该 TextBox 中插入的文本被客户端限制为指定数量的字符.

The TextBox control offers a MaxLength property, which allows the insertable text into that TextBox be clientside limited to the specified amount of chars.

我的问题:

  • 此属性是否仅在客户端和因此依赖于浏览器?
  • 我可以相信这样一个事实,即Text 属性包含的文本不超过MaxLength 已设置(仅适用于MSDN 中命名的 DisplayModes文章)还是我必须手动执行 TextBox.Text.SubString(0,所需最大长度)?
  • 这一切是怎么回事使用禁用的 java 脚本?

推荐答案

它不依赖于javascript,但这并不安全.

It does not depend on javascript but that does not make it safe.

任何人仍然可以使用 javascript(例如 XmlHttpRequest)发布请求,或者只是制作一个请求以发送比最大长度规范更多的数据.这是阻止普通用户过度填充字段的好方法,但无论如何您都需要在服务器上仔细检查.

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.

这篇关于TextBox-Control 的 MaxLength 属性有多可靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆