Textarea Maxlength
Apr 4, 2005Can any one help me to make maxlength for textarea like 105 char.
View 9 RepliesCan any one help me to make maxlength for textarea like 105 char.
View 9 Replies<script language="javascript" type="text/javascript">
<!--
/*********************
Maxtext v1.2
© 2002 Robert K. Davis
**********************/
function textlen(x,y){
var thelength = x.value.length;
window.status=thelength+' of '+y+' maximum characters.'
}
function maxtext(x,y){
tempstr = x.value
if(tempstr.length>y){
x.value = tempstr.substring(0,y);
}
textlen(x,y);
}
/*********************/
// -->
</script>
<form name="myform">
<textarea name="mytextarea"
cols="45"
rows="3"
wrap="virtual"
onkeypress="return(this.value.length<20)"
onkeydown="textlen(this,20)"
onkeyup="textlen(this,20)"
onblur="maxtext(this,20)"
></textarea>
</form>
I know that's a lot of onkeystuff ;)
The ideal solution would be not to use a script and just use:
onkeypress="return(this.value.length<20)"
However, that only works in IE and Netscape - Opera completely ignores it.
To keep it simple and work in all browsers (at least the ones I have, that is!), that was the easiest solution I could come up with. This script was tested in Opera 6, Netscape 4.x, IE 4-6 on PC, and IE 4(I think) on MAC. If you have the opportunity to test it out in another browser, please let me know the results (good or bad).
In Opera, it will not limit the textarea until the onblur() kicks in. In Opera AND Netscape, you can paste past the maxlength of the textarea, which is corrected when the onblur() kicks in.
Every single other script of its type that I've tried will produce unexpected and sometimes very amusing results (like typing backwards) in those browsers.
I would like to be able to use both a maxlength function (say, 200 character) and a counter that shows how many characters are left.
No matter what I try everything I find or try seems to use two different onkeyup functions... and I just cannot get that to work.
I would like to pass the maxlength of an HTML input field as a variable with the $.getJSON function. Here is my current code:
$.getJSON('SVRPGM',{size: '4'}, function(j){
...
}
I would like to replace '4' with something like $(this).maxLength(). Is this possible?
Setting maxlength attribute of input[type=text] or input[type=password] does not work as expected.In Firefox and Opera if maxlength is not set the field.attr('maxlength') == -1. But if I try to set field.attr('maxlength', -1) it is being set to 0 instead.
[Code]...
This plugin enforces max length on text areas and reports back the number of characters left to use.How would I add commas to the feedback message that says how many characters are left?
View 5 Replies View RelatedHow would i change back to the default length of textarea?
I have this comment area that after clicking submit i will append the new comment in the list of comments through ajax... i got one problem though, everything is working perfectly well except for the textarea that won't change back to it's default size...
EXAMPLE:
The problem is that the textareawon't change back to it's default size // let's say that the default size is rows=3
I've been trying to fix this.
Code below:
I've got this little 'textarea' script..see the code below. Now there is something strange with it. When I disable javascript from within IE 6.0, it still seems to function well... how come ?
Also I would like to build in one thing extra.. Whenever one of the buttons B or C is pressed there is a tag placed within the textarea, like it should. However I don't want the tags to be counted up to the textcount total. What do I need to adjust in the code to achieve that ? Code:
how to make a DIV into a textarea. I've noticed that Facebook does this and so does a lot of Google's stuff. Just looking to see how they pull that off.
View 2 Replies View Relatedreally need some help with validating a textarea box. basically i have
a text area box that must not have more the 910 characters entered and
they must not be spread over more than 23 lines. I could check the
total length but the problem is people could enter 1 character per
line so you would end up with 910 lines.
Is there a way to detect which textarea the cursor is positioned in? I
would not want to attach 'onkeypress' to all textareas to detect which
one I am presently in ... or is this the only option?
I need to create a page that
allows users to copy the contents of a MS Word document and paste them
into a textarea. All fine and dandy...but the tabs. I don't need to
keep the formatting, just the tabs. Is there any way to detect the tabs
and change them to four spaces or something similar? If you have any
other ideas please let me know.
I want to be able to select 3 rows of a textarea, and when pressing
"Tab/shift Tab" indent the source code edited. Can I do this with
JavaScript?
I'm using a third party libray and I can drag a diveand resize it. The
issue is, I have a textarea inside of it and I need to resize the width
of textarea and height of textarea along with it.
I know what the width and height of the div will be when it finishes
dragging (in "px"), so how do I convert the width and height in "px" to
the cols and rows of a textarea?
how can fill automatically a textarea when opening a webpage.
I want to do this by a function that has been raised in js file.
I have a DIV with various elements eg:
<div ARID="8" ARType="Char" ARDBN="Short Description">
<label class="label f9" for="arid8"Short Description</label>
<textarea class="text sr " wrap="off" id="arid8" rows=1></textarea>
</div>
I have a variable, divs, which contains the DIV's and divs[x] contains
the actual DIV I need.
What is the best (or most robust) way to access the inner textarea -
because I want to add some text to the textarea field. I know how to
add the text but want to know best way to access the textarea.
How can I make a textarea appear or disappear at the click of a button or
link?
Is there posibility to (and how to do this):
a) add a string in the current cursor position?
b) add string before and after selection in textarea e.g. selection
c) if I put with value+='' how to move cursor to position after ] and before [
I have used a textarea to display typewriter effect text. The scrollbars are displayed by default. What is the code to disable the scrollbars in a textarea form field? < scrolling="no"> does not seem to work.
View 2 Replies View Relatedhow to get value of textarea using jquery, if i hv code like.<form name = "myform">
<textarea name="msg" id="msg">
Nothing will display in my textarea after pressing an input number which have to seen on the display. The code is from a simple calculator
<form action="#" method="get" onsubmit="return false">
<p>
<textarea disabled="disabled">
I have a button next to a textarea when they click that button it launchs another window. Now I need another button that will take a value (it will be an html code) close that window, and put that value in the textarea.
Sort of like how when you click the link button in this wysiwyg editor it pops up a window that asks for some stuff and then inserts it here.
I'm using this to write html tag in me textarea. Now i'm wondering what code do i need to use so that text cursor stays in textarea after i click on the button so that i don't have to click back to textarea every time i press button. Code:
View 6 Replies View RelatedQuick script I threw together a while back. Mimics the AutoCorrect behaviour of MS Word. The list of corrections was exported from MS Word via some obscure macro that I have since lost.
Has worked in all browsers I've tested with save Netscape Navigator.
how can I change the teaxtarea size to be to is maximum at all time ?
View 2 Replies View Related