How to Limit the Characters With CreateRange in JavaScript
The JavaScript "createTextRange" function sets up a range of characters for a text box. The range of characters is set by the number of characters contained in the "createTextRange" function. Users are prompted to type in a value, so you can help readers identify what information you want them to enter in a text box.
Instructions
-
-
1
Right-click the HTML file you want to edit and click "Open With" in the popup menu. Double-click the HTML editor you use to set up the Web pages.
-
2
Locate the JavaScript tags, which is where you place all JavaScript code. If you do not have the JavaScript tags, type the following code in the file:
<script type="text/javascript"> </script>
-
-
3
Type the following code to set the text range with the "createTextRange" function:
var text = document.body.createTextRange();
text.findText("Hello World");
Replace "Hello World" with your own text.
-
1