Expand my Community achievements bar.

How to add bullet on every enter event in text field

Avatar

Former Community Member
Hello, Can someone please point me in the right direction. I am trying to add a bullet every time someone presses enter on the keyboard. this is within a textfield.



Thank you,

Howard
3 Replies

Avatar

Former Community Member
Okay instead of automatically entering a bullet, can someone help me create a button that (1) starts a new line and (2) adds a "*" at the beginning of the line. There are several multi-line textfields so the button would have to be associated with the current textfield focus.



Thank you in advance,

Howard

Avatar

Former Community Member
Hello Howard,



Try Using this line in the 'Exit' event of the Text Field you want to add bullet in;



this.rawValue = " * " + "" + this.rawValue;



I'm also a new user of LiveCycle, so I just hope this helps you.



Please do reply me in either case. Ofcourse my confident over LiveCycle will increase.



Thanx,

YD

Avatar

Level 4
Hi



I would solve it by a script that checks your multiline field for newlines by ENTER key and insert "* " in the beginning of each line.



1) create a multiline field in your form

2) insert the script below in exit event... and enjoy the magic ;)

just 7 lines of code without comments. The split function is very powerful, I really use it alot now!



===== script start =====

//value of the field to insert "* " in each line

var sFldValue = this.rawValue;

//you split text in field for each '\r' = newLines made with enter

var tmpFldArray = sFldValue.split("\r");

//tmp string you concat your out text in

var sOutStr = "";



//for each line of text insert '* ' in beginning

for(var i = 0; i < tmpFldArray.length; i++){



//need to add '\r' because split removed it

sOutStr += "* " + tmpFldArray[i] + "\r";

}



//return manipulated string to your field

this.rawValue = sOutStr;

===== script end =====



/Thomas Groenbaek

Jyske Bank

Denmark