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
401 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
Comment Utility
Hi! Nice to meet u
0
 
LVL 51

Expert Comment

by:HainKurt
Comment Utility
0
 

Author Comment

by:danny62
Comment Utility
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
Comment Utility
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
Comment Utility
not homework
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now