textarea

How to pass apostrophies from text areas to MySQL using PHP

心不动则不痛 提交于 2019-11-29 16:23:34
I have a text area that users add notes too. On the next page I use the $_POST[Comments] to show what was typed. I have an edit button to go back and see what was typed and edit the notes but when I show the $_POST[Comments] it shows everything up to an apostrophe. Example: Originally typed: Let's try this. When Editing: Let Now when I pass it to the server to do an SQL add I use the following function to protect against SQL injection function keepSafe($value) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } if (!is_numeric($value)) { $value = "'" . mysqli_real_escape_string(

Javascript: detect textarea to be full

寵の児 提交于 2019-11-29 15:38:33
I am trying detect when a textarea becomes full for creating pagination effect. Using the .length property will not work, however, because long words 'jump' to new lines. | I like to dooo| displays as | I like to | | oooodle | | dooooooodle | So what ends up happening is that the textarea always runs out of space before the .length property reaches the textarea limit. Is there any other way to detect textarea fullness? Jquery solutions are fine as well. Thanks. Majid Fouladpour You can try to check if scrollbars have appeared in your textarea. Here is a simple way to do this. Initially make

How to detect textarea size change with pure javascript?

≡放荡痞女 提交于 2019-11-29 14:43:52
I want to notify when the size of textarea changes, what event happens at that time, how can I detect it? Here is a small example using pure (without jQuery etc. dependencies) Javascript. It's using mouseup and keyup handlers and an optional intervall to detect changes. var detectResize = (function() { function detectResize(id, intervall, callback) { this.id = id; this.el = document.getElementById(this.id); this.callback = callback || function(){}; if (this.el) { var self = this; this.width = this.el.clientWidth; this.height = this.el.clientHeight; this.el.addEventListener('mouseup', function(

Javascript - Change font color of certain text in textarea

拜拜、爱过 提交于 2019-11-29 14:19:08
问题 Is there any JS function that can change the color of certain text in a textarea? For example, blar blar {blar} blar, {blar}, including { }, will be in blue. Other words will be in blank. In other words, all I need is a function that can change color of all text in { }. I've done some studies and it seems that most people say it can't be done. But I'm seeing rich text editors or those wysiwyg editors having the ability to bold or underline words. There must be a way to do it. Any suggestion

Preserve newline in text area with Ruby on Rails

廉价感情. 提交于 2019-11-29 13:33:50
问题 To practice Ruby on Rails, I am creating a blog which includes a text area (following Mackenzie Child's tutorial). When the text is submitted, all of the newlines are removed. I know variations of the question have been asked already, but I have been unable to replicate any of the results despite an entire day trying. I am not very familiar with JQuery. Is there a set of steps that will preserve the newlines? _form.html.erb <div class="form"> <%= form_for @post do |f| %> <%= f.label :title %>

Copying text of textarea into div with line breaks

为君一笑 提交于 2019-11-29 13:32:09
问题 I am tying to make a simple effect using keyup() in jQuery. I just want that when user types into the textarea then the text which user types will copy to another div named .content . When I press enter in textarea a new line is created but in my div the text is showing in the same line. My code is below or you can see demo here: http://jsfiddle.net/Pqygp/ $('.content:not(.focus)').keyup(function(){ var value = $(this).val(); var contentAttr = $(this).attr('name'); $('.'+contentAttr+'').html

jQuery / JS get the scrollbar height of an textarea

心不动则不痛 提交于 2019-11-29 13:19:30
I've got a textarea with a fixed height. When the user types text into the textarea a scrollbar will show up after the user typed some text in it. How can I get the scrollbar height using jQuery or plain JavaScript? I've been searching for this for hours, but couldn't find anything. I can't just insert a div and get the scrollbar height via the div offset because a textarea is not allowed to have child elements. Please don't give me a link to a jQuery Plug-In that does the job. I want to learn something. kennebec textarea.scrollHeight returns an integer (pixels) Kashyap Makadia $.each($(

Maximum length on a textarea in Ruby on Rails

喜你入骨 提交于 2019-11-29 13:13:52
I tried applying the :maxlenght => 40 on a textarea on my form. But it didn't work out. Can we have a length limit on a textarea? The code for text area is <%= f.text_area :data, :rows => 2, :cols => 60 , :maxlength => 140, :autocomplete => :off, :class => "textareabytes" %> Shalom Craimer Just like Rahul said, there's no maxlength attribute for textarea in HTML. Only text input 's have that. The thing you need to remember, is that RoR's text_area function (and all of RoR's HTML-generator functions) accept any argument you'll give them. If they don't recognized the parameter, then the'll just

Is there a way to dynamically change the Flutter TextField's maxLines?

我只是一个虾纸丫 提交于 2019-11-29 12:45:04
问题 I have a TextField like this: new Flexible( fit: FlexFit.loose, child: new Container( alignment: FractionalOffset.topLeft, child: new TextField( decoration: new InputDecoration( hintText: 'Add a note', ), maxLines: 1, onChanged: (value) => _showSaveOptions(value), ), ), ), I'd like to have my TextField to start out with maxLines set to 1, but as I type, I would like the maxLines to increase, so that all the text remains on the page and I don't have to scroll up. However, I also don't want to

Can I select empty textareas with CSS?

此生再无相见时 提交于 2019-11-29 12:25:37
问题 Is there a way that I can select a textarea such that $('#id_of_textarea').val() in jQuery will be '' ? I tried using :empty . I saw that CSS provides a way to select empty inputs because the text is in the value attribute ( [value=""] ). Is there an attribute for the text in a textarea? I'm looking for a selector that will work with CSS, not just jQuery. 回答1: Best solution I can think of is a CSS 3 workaround. Set the field to required (and unset it on submit if need be). Then you can use