textarea

How do I remove Word markup crap when inserting to a form?

淺唱寂寞╮ 提交于 2019-12-01 20:57:23
问题 I'm building a CMS in PHP and one dread I have is that the users will have to fill the data in from existing Word (and Excel, but nevermind that) documents. Now, I've seen what happens when they carelessly copy and paste from Word to a textarea: the database got filled with crap markup. Now, I could certainly strip all markup myself, but I'd have to start learning about it first. So I ask you: have you tested some functionality - plugins of the usual suspects (tinyMCE, FCKeditor, etc) that

Handling new lines in php

孤街醉人 提交于 2019-12-01 20:40:50
I have form in html where user can put the text in text area. I save the content of text area into MySQL database (in field of type TEXT). Then I somewhere in my aplication I need load that text and put it into array where in each index will be one line of the text. <textarea rows="10" cols="80"> Row one Row two Row tree </textarea> array (output in "php pseudocode"): $array = array(); $array[0] = Row one; $array[1] = Row two; $array[2] = Row tree; How I do it: I save it to db then I load it and use: $br = nl2br($string,true); $array = explode("<br />", $br); The reason why I use nl2br is I

Do line endings distinctions apply for html forms?

狂风中的少年 提交于 2019-12-01 19:38:54
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? No, the browser should canonicalize the line endings. 来源: https://stackoverflow.com/questions/760282/do-line-endings-distinctions-apply-for-html-forms

How to limit the textarea to only hold numbers?

拥有回忆 提交于 2019-12-01 19:30:27
I'm trying to make a date textbox on my blog, and the date is only numbers. I don't want anybody making a mistake typing a letter. Is there any way to limit the characters to only numerals? Thanks! Madhawa Priyashantha If you use jQuery, you can do it like in this jsfiddle $('input').keypress(function(e) { var a = []; var k = e.which; for (i = 48; i < 58; i++) a.push(i); if (!(a.indexOf(k)>=0)) e.preventDefault(); }); Use HTML5 input number type instead and leverage native browser validation. Thus, no JavaScript required. <input type="number" /> It has wide support in browsers and it's the

TextArea MaxLength - Supported or Not Supported?

守給你的承諾、 提交于 2019-12-01 19:28:43
I was getting ready to add a jQuery plugin to support maxlength on textarea's and noticed that the MaxLength attribute is working natively on Safari, Chrome, and Firefox. Is this thanks to HTML5 or ? Does that means having a maxlength on textareas no longer requires a jQuery type plugin? Thanks Yes, maxlength was added to <textarea> in HTML5 , so that's why you're seeing the behavior in newer browsers. Do you need a plugin? that depends...if you need to support older browsers, then yes. 来源: https://stackoverflow.com/questions/4372413/textarea-maxlength-supported-or-not-supported

How do I remove Word markup crap when inserting to a form?

别来无恙 提交于 2019-12-01 18:31:07
I'm building a CMS in PHP and one dread I have is that the users will have to fill the data in from existing Word (and Excel, but nevermind that) documents. Now, I've seen what happens when they carelessly copy and paste from Word to a textarea: the database got filled with crap markup. Now, I could certainly strip all markup myself, but I'd have to start learning about it first. So I ask you: have you tested some functionality - plugins of the usual suspects (tinyMCE, FCKeditor, etc) that helps here? Bonus for the least intrusive solution. Sadly most of the HTML editor controls I've used

How to lock the first word of a textarea?

☆樱花仙子☆ 提交于 2019-12-01 18:09:25
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 it requires no Javascript. <script type="text/javascript"> var $el = $("textarea#message_create_body");

Different maxlength validation of textarea with newlines in Chrome and Firefox

瘦欲@ 提交于 2019-12-01 18:06:27
The problem is that Firefox counts newline as "1" (\n) character while Chrome count them as "2" (\r\n) This is what I get in a textarea with maxlength=10 : This are 10 charcters for Firefox 1234 5 6 7 This are 10 charcters for Chrome 1234 5 6 The problem comes when trying to validate the form. If I have for example the following text 012345 678 In Firefox the validation passes and the data is saved, but when I try to do the same in Chrome it shows a warning, and prevents it from sending the form. "Please shorten this text to 10 characters or less(you are currently using 11 characters)" . I

How does the html5 spellcheck attribute work?

别来无恙 提交于 2019-12-01 17:58:45
How does the html5 spellcheck attribute work? I am seeing this page with Chrome 17, which is supposed to support spellcheck on <textarea> , (but not on <input type='text'> ), but when I type in some non-words in the textarea given in that page, I see no change. The spellcheck attribute is still poorly (if at all) implemented in browsers. For example, when I visit the page you mention in Chrome 18 and type misspelled words into the box “This text area should be checked for mispelled words.” the browser marks “words” as misspelled. Double clicking on some other word makes it indicated as

Auto-populating a Textarea with PHP variables

邮差的信 提交于 2019-12-01 17:48: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> <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> Note that any whitespace is represented as-is in a textarea, so newlines will result in newlines in the