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
402 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change car movement from jumping to swapping 8 93
Checkboxes 5 293
Firefox script error when open a specific page 13 106
Using two arrays on one page 9 99
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
Send secure, cloud-based, encrypted alerts and maintain HIPAA compliant messaging. Integrates priority & secure messaging into one application. Ensures IT, emergency respondents and healthcare professionals that their critical messages are never mis…

911 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

22 Experts available now in Live!

Get 1:1 Help Now