textarea

Capturing linebreaks (newline,linefeed) characters in a textarea

此生再无相见时 提交于 2019-11-30 06:21:28
I have a form with a <textarea> and I want to capture any line breaks in that textarea on the server-side, and replace them with a <br/> . Is that possible? I tried setting white-space:pre on the textarea 's CSS, but it's still not enough. Marc Have a look at the nl2br() function. It should do exactly what you want. The nl2br() function exists to do exactly this: However, this function adds br tags but does not actually remove the new lines - this usually isn't an issue, but if you want to completely strip them and catch carriage returns as well, you should use a str_replace or preg_replace I

Can I make a textarea grow with text to a max height?

。_饼干妹妹 提交于 2019-11-30 06:01:12
I'm working on a project where I have data in divs that can be various sizes. When a user clicks on one of the divs, it needs to turn into an editable textarea. The width is constant, but I'd like the height to start as the height of the original div and then grow to a max height before adding a scrollbar. Is that possible? You can use contenteditable and let the user input in a straight div , here's a demo: http://jsfiddle.net/gD5jy/ HTML <div contenteditable> type here... </div> CSS div[contenteditable]{ border: 1px solid black; max-height: 200px; overflow: auto; } There's an excellent A

Can You Use <textarea> Outside the Scope of a <form>

你说的曾经没有我的故事 提交于 2019-11-30 04:13:23
问题 I want to use the features and functionality that the <textarea> tag offers in browsers. I want to use it merely to hold a large block of information that can be viewed through the use of the scrollbars that come with the <textarea> tag. So my question is can I use it without using <form></form> tags? I want to be sure that I use it properly for contemporary and future browsers. Thanks. 回答1: Following the standards the textarea element should be a descendant of a form element. HTML5 allows to

New line characters in text area increases text length in C#

£可爱£侵袭症+ 提交于 2019-11-30 03:25:26
问题 I have this problem in my asp.net mvc application. In one of my model there is a field "Description". The database column for this fields is set to NVarchar(300) . In my view I am creating a a text area as following. @Html.TextAreaFor(m => m.Description, new { maxlength = "300" }) I am using "jquery.validate.unobtrusive.min.js" for client side validation. So when user types in the textarea and content length goes more than 300 characters it displays message "Please enter no more than 300

Remove all stylings (border, glow) from textarea

放肆的年华 提交于 2019-11-30 02:37:37
I want to remove the stylings from a textarea and leave it all white without any border or glow, if possible. I've tried with different stuff found here on SO, but nothing works (tried with FF and Chrome). So, is it possible and if so how to do it? What I've tried so far: textarea#story { // other stuff -moz-appearance:none; outline:0px none transparent; } textarea:focus, input:focus{ outline: 0; } *:focus { outline: 0; } IamShipon1988 The glow effect is most-likely controlled by box-shadow. In addition to adding what Pavel said, you can add the box-shadow property for the different browser

Get user input from textarea

自闭症网瘾萝莉.ら 提交于 2019-11-30 01:44:33
I'm new to angular2. I want to store user input from a text area in a variable in my component so I can apply some logic to this input. I tried ngModel but it doesn't work. My code for the textarea: <textarea cols="30" rows="4" [(ngModel)] = "str"></textarea> And inside my component: str: string; //some logic on str But I don't get any value in str inside my component. Is there an error with the way I'm using ngModule ? Arthur Qocharyan <pre> <input type="text" #titleInput> <button type="submit" (click) = 'addTodo(titleInput.value)'>Add</button> </pre> { addTodo(title:string) { console.log

Using jQuery, how do I force a visitor to scroll to the bottom of a textarea to enable the submit button?

此生再无相见时 提交于 2019-11-30 00:26:38
I have a registration form which contains a read-only textarea. I want to require any visitor to scroll to the bottom of the textarea, which contains terms and conditions or license agreement, before the submit button is enabled to submit their information. Here's the sample CSS code: textarea { width: 240px; height: 200px; overflow-y: scroll; } Here's sample HTML code: <form action="action.php"> <label for="email">Email Address</label><input type="text" id="email" /> <textarea readonly>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et

HTML textarea: use JavaScript to get wrapped text?

Deadly 提交于 2019-11-29 23:54:23
问题 If I've got a textarea like this: <textarea id="foo" cols=80 wrap="hard"></textarea> Is there any way, using JavaScript, to grab the hard-wrapped text? I've tried the obvious $("#foo").val() , but that returns the unwrapped text. For example, if the textarea is: <textarea id="bar" cols=5 wrap="hard">a b c d e f</textarea> The browser will wrap the text to: a b c d e f And I was some way to grab that text – "a b c\nd e f" (which, because of wrap=hard , is the text that would be sent if the

Show how many characters remaining in a HTML text box using JavaScript

我们两清 提交于 2019-11-29 22:57:05
This is my code: function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) { field.value = field.value.substring(0, 160); field.blur(); field.focus(); return false; } else { countfield.value = maxlimit - field.value.length; } } How can I display how many characters are remaining from a certain text box with a limit of 160? Nokia808Freak Dynamic HTML element function The code in here with a little bit of modification and simplification: <input disabled maxlength="3" size="3" value="10" id="counter"> <textarea onkeyup="textCounter(this,'counter',10);" id="message"> <

how to block text selection without input textarea and select items

北慕城南 提交于 2019-11-29 22:53:29
问题 How to block text selection without input textarea and select items i actually have the script that works in IE but not in other browsers, here it is: var omitformtags=["input", "textarea", "select"] omitformtags=omitformtags.join("|") function disableselect(e){ if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1) return false } function reEnable(){ return true } if (typeof document.onselectstart!="undefined") document.onselectstart=new Function ("return false") else{ document