Converts carriage returns in a string to the tag so that the input can be properly displayed in HTML. Without the script, returns in an input field are not preserved when submitting in a form. Useful for guestbooks or other times when a user's input must be preserved.
You may type a message here
Make sure to press the [Enter] key a few times.
That way you will be able to see the
conversion function in action.
Output:
JavaScript Source Code 3000: Forms: Remove Returns Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL REMOVE RETURNS:
1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript"> <!-- Original: Ascii King (chicorama@usa.net) --> <!-- Web Site: http://www.geocities.com/enchantedforest/2120 -->
<! > <! >
<!-- Begin function ConvertBR(input) { // Converts carriage returns // to <BR> for display in HTML
var output = ""; for (var i = 0; i < input.length; i++) { if ((input.charCodeAt(i) == 13) && (input.charCodeAt(i + 1) == 10)) { i++; output += "<BR>"; } else { output += input.charAt(i); } } return output; } // End --> </script> </HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center> <form> <textarea name=message rows=8 cols=50>You may type a message here