just wanted to ask how to put message in another line after the other. Here’s my code in my program:
function isEmpty(field,name,minVal, maxVal){
var msg ="";
if (field.val() >= minVal || field.val() <= maxVal){
if ( field.val().length == 0){
msg=(name + ' is empty.\n');
}
}
else{
msg=(name + ' inputted is invalid or number is more than 1000. \n');
}
return msg;
}
function validateTallyReq(par){
var msg= "Please read the following:";
msg += isEmpty($('#tallyPlankNo'),'Plank Number ',1,999) ;
msg += isEmpty($("#tallyThick"), 'Thickness value',.9,999);
msg += isEmpty($("#tallyWidth"), 'Width Value',.9,999);
msg += isEmpty($("#tallyLength"), 'Lenght Value',.9,999);
msg += isEmpty($("#tallyQty"), 'Quantity',1,3);
if (msg == "") {
} else {
showMessage(msg);
}
return false;
}
this outputs message in one line. What I want is the message to output like:
Please read the following:
Plank Number is empty.
Thickness value is empty.
Width Value is empty.
Lenght Value inputted is invalid or number is more than 1000.
Quantity is empty.
And one more question, I really dont know why it shows the length value is invalid though i dont input any value on it,. Please help.
EDIT
This is my showMessage function:
function showMessage(msg) {
$('#dialog #message').text(msg);
$('#dialog').dialog('open');
}
Try adding a
<br/>to the message after each line. That will work if the theshow()method is doing something like$("#displaydiv").html(msg);As for the unexpected
invalidmessage, it looks like the logic in this conditional is faulty:Try making it