Solved

How do I create a Javascript program that limits the amount of text entered into a text area box

Posted on 2011-09-30
5
404 Views
Last Modified: 2012-05-12
I am fairly new to Javascript. I have only been doing it for about a year. I need help. I have this project and I am lost. I have attached the file
booktxt.htm
comtxt.js
0
Comment
Question by:danny62
  • 3
  • 2
5 Comments
 

Author Comment

by:danny62
ID: 36895447
Hi! Nice to meet u
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36895618
0
 

Author Comment

by:danny62
ID: 36896853
Thank you. However, the rest of my project is: declare a global variable named maxLength and set its value to 500, and then have the browser run the init() function when the page is loaded. Create the init() function. Add the commands to the function: Create a variable named commentBox that points to the tevtarea element with the ID element.  Create a variable named contBox that points to the ID wordcount. Set the value of countBox to the textstring 0/maxlength,where maxlength is the value of the maxlength variable.Call the checkLength() function whenever the user presses the keyboard key within the commentBox object.Create the countText() funtion.Add the following commands: Declare a variable a variable named commentBox that references the comment text are box.Store the regular expression /\s/g in the variable commentregx. This regular expression selects all of the white space characters within a specified text string. Use the regular expression replace() method to replace every occurrence of white space characters within the commentBoax object with an empty text string in a variable named commentText.Return the length of the commentText variable.Create the checkLength() function.Declare a variable named evt that points to the event object under either event model. Set an if statement with the following conditions: (i)If the value returned by the countText() function is less than maxlength, then return the value true; (ii)else if the user has typed the Backspace key or the Delete key, return the value true; (iii) otherwise, return the value false.Create the updateCount() function.Add the following commands: declare the countBox variable that references the input element with the ID wordcount. Set the value of the currentLength variable returned by the countText() function. Set the value of the countBox object to the text string currentLength/maxLength,where currentLength is the value of the currentLength variable and maxLength is the value of the maxLength variable. If currentLength is less than maxLength, set the font color of the text in the countBox object to black with a background color of white; otherwise, set the font color to white on a red background. Thank you
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 36912195
sorry, but EE is not a place to post your homeworks and get them done :)
You try your best, post your code and ask for help to solve your issues...
0
 

Author Closing Comment

by:danny62
ID: 37022891
not homework
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JScript Error 2 55
bootstrap 3 date picker 5 78
Drag and drop columns in Wordpress WPDataTables 9 200
Need to get a list of users From AD 13 137
Employees depend heavily on their PCs, and new threats like ransomware make it even more critical to protect their important data.
This problem is more common than not and I will show you some things to check to solve this problem.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question