if statement - Javascript if clause not working properly -


i have following javascript/jquery:

$('#list').keypress(function (e) {   if (e.which == 13) {     var lines = $('#list').val().split('\n');     mylast = lines[lines.length - 1];     mylen = mylast.length;     if ((mylen != 8) || (mylen != 4)) {       lines = lines.slice(lines.length-1);       $('#list').val(lines.join("\n"));       alert(mylen);       return false;     }     return true;   } }); 

but jumps code block after if if length 4 or 8....

where error?

i want remove last line of textarea if it's not of given length.

it should not be:

if ((mylen != 8) || (mylen != 4)) { 

it should be:

if ((mylen != 8) && (mylen != 4)) { 

your way if 8 , not 4 getting through or if 4 not 8. need check not either


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -