Expand my Community achievements bar.

Number of lines in multiline text field

Avatar

Level 2

Hi,

Is there a way to find mumber of lines being typed by the user in multiline text field?

I tried to split the text in change event but did not help. Please provide a sample to solve this.

Thanks,

Srikanth

2 Replies

Avatar

Level 10

You can use the Exit event of the TextField to test..

Only if the user uses enter key then a new line character is added to the field.

If the user enters the text without using enter key to goto next line, then the field will wrap the text and without a new line character. In that case, it will be treated as a single line.

var xx = TextField1.rawValue.split(/\r\n|\r|\n/);

for(i=0;i<xx.length;i++){
xfa.host.messageBox("" + xx[i]);
}

Thanks

Srini

Avatar

Level 2

Hi Srini,

Thanks for your answer. I tried this option as well.

I wanted to limit the number of lines a user types in the textfield. The text wraps around the field and it will be always a single line if user wont press an enter key. I wanted to calculate the no of fields at runtime while user is still typing the text.

Could you please let me know if it is possible.

Thanks,

Srikanth