PDA

View Full Version : Set max number of rows to textarea



nani_chinni
16 Sep 2010, 3:24 AM
Hi,

I have one text area and 2 buttons (add,subtract) in a form.

I want to set max number of rows to the text area is 10.
Depending on number of rows i need to set or handle one condition.
Once text area exceeds max number of rows, then add button must be disabled.

How can i handle this event ?

If anybody know, please let me know.

Thanks,
Chinni

devtig
16 Sep 2010, 3:44 AM
try this:

textarea.on("keyup", function(field, event) {
var lines=field.getValue().split("\n").length;
//disable your add button when lines>x
});

nani_chinni
16 Sep 2010, 4:28 AM
Hi devtig,

Thanks for quick reply. Basically this for will open when one button clicks which was from outside. This code is started checking before form launched.


I want once form is opened, i need to enter rows. If number of rows increased, based on that max value button should be disabled.

Thanks,
Chinni

devtig
16 Sep 2010, 6:04 AM
This code puts an event listener on the textarea. It can and will only fire if it is rendered and visible and someone is typing in it. So it's not 'checking' before the form is launched.