Начало
Формы
Удалите Возвращения
Полезный для guestbooks или другие времена, когда вход пользователя должен быть сохранен.
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 Forms: Удалите Возвращения
<!-- 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"> <! > <! > <!-- 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 Make sure to press the [Enter] key a few times. That way you will be able to see the conversion function in action. </textarea> <p> <input type=button value="Convert Returns" onClick="this.form.output.value = ConvertBR(this.form.message.value);"> <p> Output: <input type=text name=output size=50> <p> </form> </center> <!-- Script Size: 1.41 KB -->