Forums | Mahara Community
Developers
/
Line breaks in error messages
19 November 2010, 10:57
Hi all,
I have created a new form in the files section - similar to that or the edit form. If the user forgets to populate a field I have successfully got it coming up with an error. If there are two error I would like each error to be on a line of its own, but <br> in my javascript seems to be made safe when written to the page as <br>. Does anyone know how to do this.
an excerpt of code is below [filebrowser.js]:
if (!field1 || field.value == ''){
message += '<br>'+get_string('field1isrequired');
}
if (message) {
e.stop();
replaceChildNodes(self.id + '_form_messages', makeMessage(message, 'error'));
return false;
}
Thanks,
Mark
23 November 2010, 8:26
Hi Mark,
In your case 'message' variable is considered as a single text node.
You need something like:
if (!field1 || field.value == ''){
message = SPAN(message, BR(), get_string('field1isrequired'));
}
...
23 November 2010, 11:27
Hi Rusian,
Thanks for your reply. I have tried that and get a strange error, as follows:
setting a property that has only a getter
elem.style[MochiKit.Base.camelize(name)]=_42a[name];
Mark
24 November 2010, 3:32
Does the error happen at the message string I suggested? It looks like error is related to style setting. Thugh, I have just tested multiline message string I suggested and it works without errors.