lundi 14 janvier 2019

Else if statement with length won run even though console log recognizes it

This code doesn't run the else if part at all even though i did console.log and it recognizes 0 length too. It still won't show the string. It will give the first parth though. What is the problem?

function check_width() {

    var width= $('#plwidth').val();

    if (width< 20 || width> 200) {
      $('#error_width').html("Annettu luku ei kelpaa");
      $('#error_width').show();
    } else if (width.length === 0) {
      $('#error_width').html("T&auml;yt&auml; kentt&auml;");
      $('#error_width').show();
    } else {
      $('#error_leveys').hide();
    }
  }

Aucun commentaire:

Enregistrer un commentaire