Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  101] [ 1]  / answers: 1 / hits: 18118  / 13 Years ago, wed, june 29, 2011, 12:00:00

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');
}

More From » jquery

 Answers
46

Try adding a <br/> to the message after each line. That will work if the the show() method is doing something like $(#displaydiv).html(msg);



msg += <br/>;


As for the unexpected invalid message, it looks like the logic in this conditional is faulty:



if (field.val() >= minVal || field.val() <= maxVal)


Try making it



if (field.val() >= minVal && field.val() <= maxVal)

[#91445] Tuesday, June 28, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kieraelsies

Total Points: 718
Total Questions: 103
Total Answers: 104

Location: England
Member since Sun, May 21, 2023
1 Year ago
kieraelsies questions
Tue, Aug 3, 21, 00:00, 3 Years ago
Tue, Feb 23, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
Wed, Sep 9, 20, 00:00, 4 Years ago
Mon, Sep 16, 19, 00:00, 5 Years ago
;