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
408 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:Huseyin KAHRAMAN
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:
Huseyin KAHRAMAN 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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