Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in validating text area max length

 
jaimin gohel
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have test area in the jsp page for which i have put a java script to validate the max length of it.

but the problem is that as soon as cursor id focus on the tedt area it automatically takes some blank char

the code of jsp page is (the opening and closing of the HTML tags are recplaced by "&" sign)

<td>
<textarea name="projDesc" rows="4" cols="50"
on key up ="maxlength(this.form.projDesc,100)"><%=oListProjectBean.getDescription()%></textarea><span class="requi3Field">*</span></td>

and javascript is

function maxlength(field, maxlen) {
alert("hello1jaimin"+field.value.length);
if (field.value.length > maxlen){
//alert("hello"+field.value.length);
field.value = field.value.substring(0, maxlen);

}
}
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaimin,
Are you filling the field with more than 100 characters from the description? What do you expect to happen in this case?
 
jaimin gohel
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as soon as the cursor focuses on the the description text area it automatically takes 25 to 27 blank char.

which is displayed by the alert that i have put on the javascript.

what i want is the normal focus on the text area.......
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic