jeudi 3 mai 2018

Javascript IF Statement on Input

I have the following conditional to check if there is an empty entry in my table but something really weird happens, each time the code check for the first input it changes it to TRUE or FALSE. i.e:

Code: Null (empty) Mon: 45.6
It should just show me an alert not changes the Code to "TRUE"

function Revisar_Espacios_Vacios(){

Rev_Tabla = document.getElementById("Registros");
Rev_len = document.getElementById("Registros").rows.length;

 for (y = 1; y < (Rev_len); y++) {

    for (x = 0; x <= 1; x++) {
        //Extraccion de la primera letra del codigo.

        if (x == 0) {

            Rev_Codigo = Rev_Tabla.rows[y].cells[0].getElementsByClassName('CLPMRY')[0]; //Code
            Rev_ck1 = Rev_Tabla.rows[y].cells[2].getElementsByClassName('NewR')[0]; //Amount

            alert(Rev_Codigo.value);    
            /*Check No°1 When there's no Code but Amount */
            if( Rev_Codigo.value == "" && Rev_ck1.value != ""){

                    alert('Codigo Faltante en la fila #' + y + " asignado el codigo: "  );
                    //Somehow this validation changes my Input InnerHtml to True or False
            }
            else
            {
            /*Check No°2 When there's No Amount but Code*/
            if( Rev_Codigo.value =! "" && Rev_ck1.value == "" ){    
                    alert('Letra mensual Faltante en la fila #' + y + " asignado el codigo: "  );

         //Somehow this validation changes my Input InnerHtml to True or False
            }

            else
            {

            }

        }
        }
        }
       }
  }

Aucun commentaire:

Enregistrer un commentaire