textarea

New Line in Textarea to be converted to <br/>

我怕爱的太早我们不能终老 提交于 2019-12-18 10:09:41
问题 There's a lot of threads here about converting br/> or preserving newlines across different languages, but not many regarding textarea. I have this script: var boxText = ""; $("textarea.BoxText").live('dblclick', function () { boxText = $(this).val().replace(/ /g, "<br/>"); $(this).replaceWith( '<div class="BoxText">' + $(this).val() + '</div>' ); }); $("div.BoxText").live('dblclick', function () { $(this).replaceWith( '<textarea form="HTML" class="BoxText">' + boxText + '</textarea>' ); });

Get and echo inputs from textarea repeatedly [closed]

邮差的信 提交于 2019-12-18 09:38:31
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I have a simple HTML form like this: <form action="index.php" method="post"> <textarea id="question" name="question"></textarea> <input type="submit"/> </form> And the procedure that I'd like it to be is something like described here: Type something in the text area and click

Find value of current line of a <textarea> using javascript

吃可爱长大的小学妹 提交于 2019-12-18 09:16:18
问题 How can I find the value of the current line of a textarea? I know I have to find the caret position, but then find everything before it up to the last \n and everything after it to the next \n. How can I do this? 回答1: A simple way would be to just loop: var caretPos = 53, // however you get it start, end ; for (start = caretPos; start >= 0 && myString[start] != "\n"; --start); for (end = caretPos; end < myString.length && myString[end] != "\n"; ++end); var line = myString.substring(start + 1

Get the character count of a textarea including newlines

佐手、 提交于 2019-12-18 07:13:50
问题 I tested this code in Chrome and there seems to be a bug involving the newlines. I am reaching the maxlength before I actually use all the characters. var ta = document.getElementById('myText'); document.getElementById('max').innerHTML = ta.maxLength; setInterval(function() { document.getElementById('count').innerHTML = ta.value.length; }, 250); <textarea id="myText" maxlength="200" style="width:70%;height:130px"> Lorem Ipsum is simply dummy text of the printing and typesetting industry.

how to get selected text inside a textarea element by javascript?

China☆狼群 提交于 2019-12-18 05:22:29
问题 I'm not familiar with such attributes, can someone provide a simple demo? I need it to be done without any libraries. 回答1: <script type="text/javascript"> function ShowSelectionInsideTextarea() { var textComponent = document.getElementById('mytextarea'); var selectedText; // IE version if (document.selection != undefined) { textComponent.focus(); var sel = document.selection.createRange(); selectedText = sel.text; } // Mozilla version else if (textComponent.selectionStart != undefined) { var

JavaFX 2 TextArea: How to stop it from consuming [Enter] and [Tab]

时光毁灭记忆、已成空白 提交于 2019-12-18 04:15:06
问题 I want to use a JavaFX TextArea as though it were exactly like a multi-line TextField. In other words, when I press [Tab] I want to cycle to the next control on the form and when I press [Enter] I want the Key.Event to go to the defaultButton control (rather than be consumed by the TextArea). The default behavior for TextArea is that [Tab] gets inserted into the TextArea and [Enter] inserts a new-line character. I know that I need to use EventFilters to get the behavior that I want, but I'm

CSS to change the cursor style of the resize button on a textarea

半世苍凉 提交于 2019-12-18 03:57:51
问题 I noticed that the resize button on my text area when hovered and/or clicked is staying as an arrow. It seems to me like it should be a pointer. seeing as there is css to remove or add the resize tool to a textarea, resize:none; and css to change the cursor of the whole textarea, cursor:pointer; but it seems like there should be a css parameter to control the cursor of just the resize button. I've been looking around a bit and can't seem to find the property though. I can think of a few ways

display line breaks asp.net mvc razor

坚强是说给别人听的谎言 提交于 2019-12-17 23:34:17
问题 I'm using the following to make the text output the line breaks entered in a <textarea> HTML element. MvcHtmlString.Create(Model.Post.Description.Replace(Environment.NewLine, "<br />")) Is there a nicer way to do this? 回答1: Your code is vulnerable to XSS attacks as it doesn't HTML encode the text. I would recommend you the following: var result = string.Join( "<br/>", Model.Post.Description .Split(new[] { Environment.NewLine }, StringSplitOptions.None) .Select(x => HttpUtility.HtmlEncode(x))

CSS Input field text color of inputted text

[亡魂溺海] 提交于 2019-12-17 23:26:11
问题 I have an input field, and the color of the text in it is black. (I'm using jquery.placeholder) Let's say the text in there is "E-Mail" When you click on this field, the black placeholding text dissapears (thanks to jquery.placeholder). Any text inputted into this field, I want it to turn red, and when you deselect this field, I want it to stay red. At the moment, the text saying "E-Mail" is black, and anything I type into is red, which is great, but as soon as i deselect, it goes back to

Why isn't this textarea focusing with .focus()?

假如想象 提交于 2019-12-17 22:38:33
问题 I have this code to focus a textarea when the user clicks on the "Reply" button: $('#reply_msg').live('mousedown', function() { $(this).hide(); $('#reply_holder').show(); $('#reply_message').focus(); }); It shows the reply form, but the textarea won't focus. I'm adding the textarea via AJAX which is why I am using .live() . The box that I add shows (I even add #reply_msg via AJAX and stuff happens when I mouse down on it) but it won't focus on the textarea. Edit My HTML looks like: <div id=