My Project at work is near release. Its a grueling yet exciting time here. Too much work on desk to handle. Deadlines visible closer than ever. Shifting priorities, severities, what can be delivered, what can be patched later, Its a very tough time for all of us in the team. But I feel we are doing well. Things are much in control, as I see it, than what they were when I first came on. Life is fast now.. but On this memorial day weekend, I am assuming, I will be relatively free and will start on SarathOnline again. Till then.. Shine on..
Textareas allow new lines to enter. These are represented by \n (1) or \r\n (2) characters. But when you save to DB you have a limit to certain length of chars. There is no maxlength attribute in HTML that will stop you from entering data. This is generally acomplished by Javascript. You do a onkeyup hook and stop event or trim after textarea.value.length > maxlength. There are many other solutions out there.. But.. Here is the problem that most of those solutions overlook, How do you deal with the count on \n and \r\n representations. Lets first see how it matters. If the text entered has new lines, the length is calculated differently in Firefox and IE. When you enter a Text like 01234 567890 You expect the textarea.value.length to be 11. (10 chars + new line).On the backend, however, java would recieve it as 12 chars (10 chars + \r\n) (this is irrespective of FF or IE). So you are effectively saving 12 chars to DB. Worse yet, IE seems to figure textarea.value.length as 12 (