Textbox client JS value acquisition in the background

Source: Internet
Author: User

Textbox client JS value acquisition in the background

Requirements:The client cannot enter the value, but it can assign a value through JS and obtain the value assigned by JS on the server side.

Recently, I was using vs2005 as a project. I encountered such a problem that the content of textbox was always inaccessible. I finally found it. It turned out to be a ghost of readonly.

Readonly
Gets or sets a value to indicate whether the content of the textbox control can be changed.

Important:
When a message is sent back, the text value of the Textbox Control (whose readonly property is set to true) is sent to the server, but the server does not process the read-only text box. This prevents malicious users from changing the read-only text value. The value of the text attribute remains in the view state between sending and sending, unless it passes through the server sideCodeModify.

You can use either of the following methods to prevent client changes:
1. Use the text control of input instead;
2. Do not set readonly directly by using properties, but by using textbox1.attributes ["readonly"] = "true" in the code.
3. textbox1.attributes ["contenteditable"] = "false ";
It is equivalent to readonly = "true" or setting textbox attributes directly from the foregroundContenteditable = "false"

 

Source: http://blog.csdn.net/yanwu616/archive/2010/04/28/5534879.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.