You need different methods to disable a text field on your web page for Netscape Navigator and Internet Explorer.
One way to work around this problem is to use JavaScript to do browser
detection and dynamically generate your HTML, based on the browser version; however, this method can clutter your page. Also, this is not efficient, if all you are trying to do is disable a text field.
Another way to disable a text field is to place the ReadOnly and onFocus attributes in the same text field tag. To do this, follow these steps:
- Open or create a new Normal page in FrontPage.
- On the Insert menu, point to Form, and then click One-Line Text Box.
- Click the HTML tab.
- In the <form> tags, change the following HTML code from
<input type="text" name = "T1" size="20">
to the following HTML code:
<input type="text" name = "T1" size="20" ReadOnly=True onFocus=this.blur()>
- Click the Normal tab, and save your page.
This method works for Internet Explorer, because it supports the ReadOnly attribute on the input tag and ignores the onFocus attribute.
This method works for Netscape Navigator, because it ignores the ReadOnly attribute and runs the blur() method, which removes the insertion point from the field.
This method creates a text field in both browsers that the user cannot edit. The text field still has all the JavaScript flexibility of an HTML text field.
NOTE: In Microsoft Internet Explorer, you can use the ReadOnly=True code to disable the text field. The Dynamic HTML/HTML object model of Netscape Navigator does not support elements such as ReadOnly=True or Disabled=True; however, you can blur the focus of the text field. If you programmatically blur the focus in Internet Explorer, the browser leaves a flashing insertion point in your text field. This can create incompatibilities with disabling a text box.
The flashing insertion point may not seem like a problem, but if there is data in the field and the user selects the field, the user sees an insertion point. If the user wants to clear the data in the field, they press BACKSPACE. The BACKSPACE key is a shortcut for the
Back button in Internet Explorer, so the Web browser goes back a page. This can possibly result loss of data in the form fields.
The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.