Line breaks in showFieldMsg()?

Joey Wan Kenobi
Tera Guru

Hello,

Does anyone know of a way to insert line breaks in a field message within the showFieldMsg() method?

Tongue Twister not intended.

Thanks

18 REPLIES 18

... not really.


I need the line break due to "optical" reasons .. and adding many lines looks kind of "uncool" for me, due to the visible line due to color change ...


Yes I agree it doesn't look as cool as it would if it were one block of text. Alas, I don't know the solution to that


GregM1
Tera Contributor

Try to use simillar code:

var message_text = g_form.getValue('field_1')  + '\n' + g_form.getValue('field_2'); //just a sample of message with line breaks
var controlID = g_form.getControl('field_name').id + '_fieldmsg'; //It will give you id of div containing error, warning, info message
g_form.showFieldMsg('field_name', message_text, 'error'); // here comes the code that shows message
document.getElementById(controlID).style.whiteSpace = 'pre-wrap'; //magic happens here

niteshupare
Kilo Contributor
I tried with \n but it didn't worked for me. So I wrote 2 g_form.showFieldMessage() for both lines and it worked as expected.



I don't know whether it is currect way to do it but it did worked for me.

Chaithanya10
Tera Contributor

Hello,

 

you can use "<br\>" to make it in next line.

 

Ex message: "First line.Second line"

 

you should enter the string as "First line.<br\> <br\>second line"

 

output:

First line

Second Line

 

 

Note:Please accept the sution if it works for you.