473,382 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Overwrite contents of textarea

3
Hi

I have a text area and a label.

label(cntfieldld) represents the number of characters that still can be entered in the text area(xtxExpertise).

I have written the following code:

function textCounter (txtExpertiseId, cntfieldId, maxlimit)
{
Count = cntfieldId.value;
If (txtExpertiseId.value.length > 2000)
cntfieldId.value=0
else
cntfieldId.value = maxlimit - txtExpertiseId.value.length;
if (txtExpertiseId.value.length > maxlimit) // if too long...trim it!
{
ab= window.confirm (" Please enter fewer than 2000 characters");
if (ab == true )
txtExpertiseId.value = txtExpertiseId.value.substring (0, maxlimit);
else
txtExpertiseId.value = txtExpertiseId.value.substring (0, maxlimit-count);
}
}


The code is working fine but i am getting a problem when i overwrite(by pasting) the contents of the textarea , two events are getting invoked-onkeyPress and onPaste events.

Can anyone help me to resolve this....

Thanks in advance
May 24 '07 #1
4 1189
kenobewan
4,871 Expert 4TB
What errors do you receive? You state that the code works fine, but there appear to be syntax errors.
May 24 '07 #2
Plater
7,872 Expert 4TB
This is javascrupt? For a webbased page?
HTML textboxes can get a maxlength value assigned to them, so it will not allow more then X amount of characters. That should help.

Then you just worry about counting how many more characters they have left.
Expand|Select|Wrap|Line Numbers
  1. function UpdateLabel()
  2. {
  3.    var maxlimit=2000;
  4.    mylabal.value=(maxlimit - mytextbox.value.length);
  5. }
  6.  
Call that in an onkeypress event?
May 24 '07 #3
bgruha
3
What errors do you receive? You state that the code works fine, but there appear to be syntax errors.
confirm box is opening two times simultaneously.one when im pressing the ctrl key and the other when im pressing 'v'
May 24 '07 #4
Plater
7,872 Expert 4TB
confirm box is opening two times simultaneously.one when im pressing the ctrl key and the other when im pressing 'v'
Check the keyvalue before doing anything?
May 24 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: phil_gg04 | last post by:
Dear CSS Experts, I want to make a textarea fill all the available width. This is something I've done before but mostly by trial and error; now I want to understand what is going on. So I try:...
1
by: ma740988 | last post by:
Trying to some of my reading on file manipulation (ifstream/ofstream/fstream) into action. So now consider. # include <iostream> # include <fstream> # include <cstring> # include <sstream> ...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
12
by: PMA | last post by:
Hi all, I am porting a web application from IE 6.0 to FireFox 1.5. I have solved almost all compatibility issues (quite a lot but not too bad) except two of them : 1) Clipboard access thru'...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: korggrok | last post by:
I have a dialog window that pops up from the main app browser window. The window contains a form (name="savechanges") that includes an input (name="sql") that is a textarea input. The dialog...
6
by: gilbert.george | last post by:
Hi, I am setting the width of a textarea using the style.width to ensure the textarea is exactly the right width. I want to set the height/rows of the textarea depending on it's contents (so...
3
by: saytri | last post by:
I am displaying the contents of a textfile in a textArea. I want that when i edit this text in the textArea it is automatically saved in the textfile. I have wriitten this code, but the problem is...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.