textarea

Setting (or Reading) value of Cursor/Caret in HTML TextArea

杀马特。学长 韩版系。学妹 提交于 2019-12-01 14:39:31
I am trying (and failing) to implement a drag&drop mechanism into an HTML textarea. Drag&Drop mechanism is relatively easy with jQuery or Scriptaculous (we use both), so I am willing to accept an answer that uses either of these two. Problem is, I cannot seem to find a way to read or set the insertion point. What I ultimately want to be able to do is determine the drop location, do some kind of mathematical calculation to determine where on the textarea that is exactly, then set the caret position (or insertion point), and place (insert) dropped text there. I can handle the calculations, I

Preventing “Enter” from submitting form, but allow it on textarea fields (jQuery) [duplicate]

丶灬走出姿态 提交于 2019-12-01 14:20:13
问题 This question already has answers here : Prevent users from submitting a form by hitting Enter (30 answers) Closed 3 years ago . $(window).keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); return false; } }); The above is the code I got which effectively kills the "enter" key as a form submitter throughout the system, which is exactly what I want. However, the enter key is also disabled on textarea tags - which the users should be able to hit enter on in order to go

How can I add a text in textarea form (in HTML tag) by selenium python?

半腔热情 提交于 2019-12-01 13:48:54
I have this HTML code: <form class="_b6i0l"><textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_bilrf" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea> <textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_bilrf" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea> </form> I want write a text in the filed. But, this error is happened: selenium.common.exceptions.ElementNotInteractableException: Message: Element <textarea class="_bilrf"> is not reachable by keyboard My code which sends the text is: add_comment

Setting (or Reading) value of Cursor/Caret in HTML TextArea

会有一股神秘感。 提交于 2019-12-01 12:59:42
问题 I am trying (and failing) to implement a drag&drop mechanism into an HTML textarea. Drag&Drop mechanism is relatively easy with jQuery or Scriptaculous (we use both), so I am willing to accept an answer that uses either of these two. Problem is, I cannot seem to find a way to read or set the insertion point. What I ultimately want to be able to do is determine the drop location, do some kind of mathematical calculation to determine where on the textarea that is exactly, then set the caret

avoid textarea rows/cols error?

房东的猫 提交于 2019-12-01 11:44:57
I am using a few page validation tools one problem i have is they tell me textarea must have rows and cols attribute. If i am setting this in CSS or using display:none (and using it to hold raw text data) can i do something to skip? it seems like the only answer is rows="0" cols="0" each time i use it. But i have a feeling that is not a good solution. Stop using a textarea . If you want something to hold raw data, then use a <script> element (if you plan to access it with JS) or an input of type hidden (if you plan to submit it as form data). Don't use semantics that say "Let the user enter

Storing the line number of all the occurrence of particular character in javascript

允我心安 提交于 2019-12-01 11:41:28
I am following this link Find out the 'line' (row) number of the cursor in a textarea . I want to store the line number of all the occurence of "{" in array while user write in textarea. I want to display the array content after it. Here is source code , I have tried: <textarea rows="10" cols="100" id="editor" onkeypress="hello(event);" ></textarea> <div id="lineNo"></div> <script> function hello(e) { var keyp=e.charCode; var c=0,i; var arr=new Array(); if(keyp=='123') { var arr[c++]=getLineNumber(); } for (i=0;i<arr.length;i++) { document.getElementById("lineNo").innerHTML="Array content is..

Detect selected text in a text area with javascript

我的梦境 提交于 2019-12-01 11:33:37
Is it possible to detect what text has been selected in a text area using Javascript? I'm looking to show the user controls only when they have selected text Tim Down I've written a cross-browser function for getting the text selected in a textarea or text input and after some toing and froing the final version is I think the best one I've seen. I've posted it on Stack Overflow a few times before. Here's one example: Is there an Internet Explorer approved substitute for selectionStart and selectionEnd? To detect when the user makes a selection in a textarea, you can use the select event: var

ASP.NET MVC - How can I set the Default Value in a Strongly Typed TextArea?

[亡魂溺海] 提交于 2019-12-01 10:42:56
I'm trying to make a TextArea have a default value. <%: Html.TextAreaFor(Function(model) model.Description, 5, 10, New With {.Value = "Description: "})%> This works properly in a TextBoxFor but doesn't work in a TextAreaFor Am I missing something very obvious? You can specify the value for Description property in the controller action when creating the model, and pass that model to the View: public ViewResult Create() { var model = new MyPageModel() { Description = "Description: "; } return View(model); } In the view: <%: Html.TextAreaFor(model.Description) %> Setting the value won't work as

js 替换特殊符号

三世轮回 提交于 2019-12-01 10:01:42
[]()+?^$等等里面要用到的 特殊字符 都要转义。 即在前面加 \ <textarea id="tarea1" style="width:300px;height:300px"></textarea> <textarea id="tarea2" style="width:300px;height:300px"></textarea> <input type="button" value="ok" id="btnok" onclick="btnok_click()" /> <script> function btnok_click() { debugger var i = document.getElementById("tarea1").value; var res = TransferString(i); var t = document.getElementById("tarea2"); t.innerText = res; } function TransferString(content) { debugger var string = content; try { //string = string.replace(/[\r\n]/g, ","); string = string.replace(/\^/g, "1"); } catch (e) { alert(e

Scroll without a scrollbar

空扰寡人 提交于 2019-12-01 09:34:11
Sample form: <!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> * {font:13px arial; color:white;} body {background:black;} label {display:inline-block; width:50px;} input, textarea {margin:0; border:1px solid red; padding:0; background:green;} textarea {width:300px; height:100px;} </style> </head> <body> <form action="#"> <div><label for="entry_0">Name</label><input type="text" id="entry_0"></div> <div><label for="entry_1">Email</label><input type="text" id="entry_1"></div> <div><label for="entry_2">URL</label><input type="text" id="entry_2"></div> <div id="parent"><textarea