"保护"来自输入的文本框值(HTML表单) [英] "Protect" text box value from input (HTML form)

查看:249
本文介绍了"保护"来自输入的文本框值(HTML表单)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的意思是让它的内容不可修改,所以我不知道是否有可能为HTML文本框赋值并保护它。当表单被提交时,确定它是提交的这个值。



顺便说一句,我认识到更简单的方法不是听这个输入,只是分配它,但它会派上用场,可以做到上面所说的。



我希望这个问题很清楚,请问任何需要澄清的问题。



预先感谢!

编辑:我绝对不够清楚,但我试图表达我应该保存提交后的值(在客户端不可修改)

解决方案

不,它不是。您绝不应该信任用户输入,其中包括表单提交。



其他答案告诉您如何将字段标记为只读。如果你想显示一个特定的值,同时显示它不是旨在进行编辑,这是非常有用的。



然而,它仍然可以被修改使用Firebug,DOM Inspector等。或者,他们可以提交HTTP请求,而不使用浏览器。



我建议将值存储在会话中。

I was wondering whether it is possible to assign a value to an HTML text box and protect it.

What I mean is make it´s content unmodifiable, so that when the form gets submitted im "sure" it was this value which was submitted.

BTW I realize the easier way would be not to "listen" fot this input and just assign it but it would come in handy to be able to do what´s stated above.

I hope the question is clear enough, please ask for any needed clarification.

Thanks in advance!

EDIT: I was definitely not clear enough but I tried to express that i should hold the value after submitted (not modifiable in client side)

解决方案

No, it's not. You should never trust user input, which includes form submissions.

The other answers tell you how to mark the field as read-only. This is useful if you want to display a particular value, while showing that it's not intended to edited.

However, it can still be modified with Firebug, DOM Inspector, etc. Or, they can just submit a HTTP request without using the browser at all.

I would recommend storing the value in a session instead.

这篇关于"保护"来自输入的文本框值(HTML表单)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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