textarea

粘贴复制

匿名 (未验证) 提交于 2019-12-02 23:38:02
方法二: 方法三: // 第三种 ios 设备和 android设备均正常,但是pc端没有//定义函数window.Clipboard = (function(window, document, navigator) { var textArea, copy; // 判断是不是ios端 function isOS() { return navigator.userAgent.match(/ipad|iphone/i); } //创建文本元素 function createTextArea(text) { console.log(text,"text"); textArea = document.createElement('textArea'); console.log(textArea,"textArea"); textArea.innerHTML = text; textArea.value = text; console.log(textArea.value,"textArea.value"); document.body.appendChild(textArea); } //选择内容 function selectText() { var range, selection; if (isOS()) { range = document.createRange();

How can I disable the ENTER key on my textarea?

为君一笑 提交于 2019-12-02 23:01:13
<form name='qform'> <textarea name='q' rows='3' cols='60' wrap='hard' id='q' onkeydown="if (event.keyCode == 13) document.getElementById('clickit').click()"></textarea> <input type='button' value='search' id='clickit' onclick="get();"> </form> I have this form... it doesn't have a submit button because I am using jquery and under this form is a div area where the results will be shown. It is a search engine that does not have an input box but instead has a textarea. This is because it will be a multiple word searcher. The problem is that if I press enter, the query is submitted and everything

TEXTAREAs scroll by themselves (on IE8) every time you type one character

安稳与你 提交于 2019-12-02 22:58:35
IE8 has a known bug (per connect.microsoft.com ) where typing or pasting text into a TEXTAREA element will cause the textarea to scroll by itself. This is hugely annoying and shows up in many community sites, including Wikipedia. The repro is this: open the HTML below with IE8 (or use any long page on wikipedia which will exhibit the same problem until they fix it) size the browser full-screen paste a few pages of text into the TEXTAREA move the scrollbar to the middle position now type one character into the textarea Expected: nothing happens Actual: scrolling happens on its own, and the

textarea的高度自适应

匿名 (未验证) 提交于 2019-12-02 22:56:40
1.只读状态下的高度自适应 // maxHeight为最大高度 function autoTextarea ( maxHeight ){ $ . each ( $ ( "textarea" ), function ( i , n ){ $ ( "#textarea" ). css ( "overflow" , "hidden" ); var _height = n . scrollHeight ; $ ( n ). height ( _height ); if ( $ ( n ). height () > maxHeight ){ $ ( n ). height ( maxHeight ); $ ( "#textarea" ). css ( "overflow" , "auto" ); } }) } 效果图: 2.编辑状态下的高度自适应 $ . each ( $ ( "textarea" ), function ( i , n ){  $ ( n ). height ( n . scrollHeight );  $ ( n ). on ( ‘ input ‘, function (){ if ( n . scrollHeight > n . offsetHeight ){   $ ( n ). height ( n . scrollHeight )    } }) }) 删除时

解决textarea标签上传java后台保存原本样式问题

匿名 (未验证) 提交于 2019-12-02 21:53:52
form表单里的textarea标签内容上传到java后台,并把空格换行上传到数据库mysql。 1.前端先不用设置,java后台接收处理。 String pt_work_experience=request.getParameter( "pt_work_experience" ); //25. System. out .print( "25. 01==" +pt_work_experience+ " \n " ); pt_work_experience=pt_work_experience.replace( "/ \n | \r\n /g" , "<br>" ); System. out .print( "25. 02==" +pt_work_experience+ " \n " ); 把这个 pt_work_experience 保存在mysql数据库即可。 2.前端接收java后台传过来的teatarea值(包含换行和空格): datas [ i ].jingli是java传过来的teatarea值 。 //textarea var work_jingli = datas [ i ].jingli; var reg = new RegExp ( "<br>" , "g" ); work_jingli = work_jingli . replace ( reg , " \r\n

Capitalize input text in Javascript

本小妞迷上赌 提交于 2019-12-02 21:15:40
问题 In a form, I have two buttons to transform text to uppercase and lowercase. I am using this function to transform input text to upper case: document.xyz.textinput.value=document.xyz.textinput.value.toUpperCase() Now, I want to add a new button to capitalize each word. Is it possible to achieve this with the following code? document.xyz.textinput.value=document.xyz.textinput.value.capitalize() Thanks 回答1: Try This: document.xyz.textinput.value = document.xyz.textinput.charAt(0).toUpperCase() +

input元素默认选中设置

匿名 (未验证) 提交于 2019-12-02 20:34:42
单选按钮: 加checked=checked属性 复选框 加checked=checked属性 select下拉框 加selected=selected属性 date日期: value='2018-06-06' 普通文本框: value="你要默认展示的值" textarea: 没有value属性,写在textarea标签里边 文章来源: input元素默认选中设置

Detecting specific words in a textarea submission

半城伤御伤魂 提交于 2019-12-02 20:33:23
问题 I have a new feature on my site, where users can submit any text (I stopped all HTML entries) via a textarea. The main problem I still have though is that they could type "http://somewhere.com" which is something I want to stop. I also want to blacklist specific words. This is what I had before: if (strpos($entry, "http://" or ".com" or ".net" or "www." or ".org" or ".co.uk" or "https://") !== true) { die ('Entries cannot contain links!'); However that didn't work, as it stopped users from

Using nl2br to preserve textarea new lines to mysql… how to return data to textbox nicely?

你离开我真会死。 提交于 2019-12-02 20:04:50
问题 I have a form with a textarea whose results are inserted into a mysql database. I'm using nl2br to preserve the line breaks. However, because this inserts br's in the text, when a user goes to edit what they've entered in the textarea, it shows all the br's in the textarea which were saved in mysql (looks ugly for people who don't know html). So, if I don't use nl2br, the line breaks look nice when echoed back in the textarea but not saved in the database correctly. If I use nl2br, the line

Can't see components in JScrollPane

坚强是说给别人听的谎言 提交于 2019-12-02 19:47:43
问题 I'm using a JScrollPane to hold a JTextArea for a large area of text. I add the TextArea directly to the JFrame, it works fine. But I add it to the scrollpane and add the scrollpane, I don't see the textarea. Here's my SSCCE: public class foo extends JFrame{ //gui elements JTextArea chatMonitor = new JTextArea(); JScrollPane textPane = new JScrollPane(); ChatFrame(final String nickname, final String login, final String server, final String channel){ setSize(500,500); chatMonitor.setEditable