textarea

Validation of textarea

对着背影说爱祢 提交于 2019-12-04 04:21:20
How to do I validate a textarea in a form? i.e, it should not be empty or have any new lines, and if so raise an alert. Code: <script> function val() { //ifnewline found or blank raise an alert } </script> <form> <textarea name = "pt_text" rows = "8" cols = "8" class = "input" WRAP ></textarea> <input type=""button" onclick="val();" </form> The easiest way I could think of: function validate() { var val = document.getElementById('textarea').value; if (/^\s*$/g.test(val) || val.indexOf('\n') != -1) { alert('Wrong content!'); } } Sarfraz Try this: <textarea id="txt" name = "pt_text" rows = "8"

Do line endings distinctions apply for html forms?

北战南征 提交于 2019-12-04 03:50:15
问题 I know that the line endings used for files vary depending on the OS. I was wondering, if a user pastes text into a http form input such as a textarea, does the line ending character(s) for what gets sent depend on the OS in the same way? 回答1: No, the browser should canonicalize the line endings. 来源: https://stackoverflow.com/questions/760282/do-line-endings-distinctions-apply-for-html-forms

Auto-populating a Textarea with PHP variables

折月煮酒 提交于 2019-12-04 03:25:27
问题 How do I auto-populate the text area below with two PHP variables, $submission and $fullurl? <form method='post' action='index.php'> <br /> <textarea name="tweet" cols="50" rows="5" id="tweet" ></textarea> <br /> <input type='submit' value='Tweet' name='submit' id='submit' /> </form> 回答1: <textarea> s are given default values like so: <textarea>value</textarea> So use something like: <textarea name="tweet" cols="50"rows="5" id="tweet"><?php echo $submission ?> <?php echo $fullurl ?></textarea

How to lock the first word of a textarea?

孤街浪徒 提交于 2019-12-04 03:24:59
问题 Basically I need to create a textarea that is character limited, but will have a single word at the beginning, that they can't change. It needs to be a part of the textarea, but I don't want users to be able to remove it or edit it. I was thinking I could create a JQuery function using blur() to prevent the user from backspacing, but I also need to prevent them from selecting that word and deleting it. UPDATE I wrote this JQuery which seems to work great! However I like the solution below as

How to know what lines / chars are currently visible in a textarea?

元气小坏坏 提交于 2019-12-04 02:59:52
问题 Online editor with "live preview": there is a textarea on the left and a preview div on the right. Whenever the textarea changes, the preview is updated. This works well for small documents; for very long documents however, it becomes sluggish, because the preview has lots of DOM elements that are constantly repainted. It would be better to only send to the preview, the part of the textarea that is currently visible (since it's the one that needs to be previewed). There is a heuristic way to

Executing Javascript from inside textarea (custom JS console)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 02:13:38
问题 I am interested in building a text editor in a CMS backend that allows users to write Javascript into a textarea and test it while editing. The closest I can think of is something like. document.head.appendChild(document.createElement('script')).src='http://site.com/file.js'; But instead of .src='http://site.com/file.js'; I would need to fill the script element with the textarea value. Does anyone have any idea as how to handle something like this? 回答1: I have written a simple one of these

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

你离开我真会死。 提交于 2019-12-04 02:13: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++]

Flex TextArea - copy/paste from Word - Invalid unicode characters on xml parsing

六眼飞鱼酱① 提交于 2019-12-04 02:06:05
问题 EDIT: Please visit here: Flex textArea remove/replace invalid little squares Seems to be the issue & need to find a solution for this. ORIGINAL: We have an application where users can create an email message & send it to different users. We create the email message as an XML message (sender, destination, subject, body, etc.) & put it on the queue. Another application picks up the message, parses it & sends out the emails. We have no control over it. Now the problem is during testing, our

Auto scroll down a TextArea

元气小坏坏 提交于 2019-12-04 02:04:17
问题 I have a TextArea that doesn't scroll down when I add text in it. I thought using this answer, but my TextArea is connected to a StringProperty like this : consoleTextArea.textProperty().bind(textRecu); So the answer doesn't work for me, is there another way to make my TextArea scroll down every time I update it by the binding? 回答1: Here is fast demo of what i meant in comment about adding listener to the textRecu. Yep consoleTextArea.textProperty() can't be changed because of a binding. But

Can't update textarea with javascript after writing to it manually

人走茶凉 提交于 2019-12-04 00:23:25
I'm writing an online application where I save some texts to the database. There are like 5 "textarea"-s and 5 "input type=text"-s. I'm also implementing a search to easily find and edit the DB entries. A new select window is displayed(using prototype and ajax), and when clicking on any of its entries the below form gets populated (it's the same form that was used to add new results). Now here's where the problem arises.... If i add a new form or edit any existing one ALL TEXTAREA fields that were modified, get locked or something like it (only textareas, the inputs still work) ... They won't