Cant find a way to find text boxes who are null

hello my code goes like


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Our Local site</title>
        <script type="text/javascript">
            
        function ab(){
            var container = document.getElementById ("body");
            var abc = container.getElementsByTagName ("input");
            alert("abc");
            
        }
        
        
        
        </script> 
    </head>
    <body>
        <input id="t1"type="text" placeholder="table name"><br>
        <input id="s1"type="text" placeholder="skill">
        <input id="s2"type="text" placeholder="skill">
        <input id="s3"type="text" placeholder="skill">
        <input id="s4"type="text" placeholder="skill">
        <input id="s5"type="text" placeholder="skill">
        <input id="s6"type="text" placeholder="skill">
        <input id="s7"type="text" placeholder="skill">
        <input id="s8"type="text" placeholder="skill">
        <input id="s9"type="text" placeholder="skill">
        <input id="c1"type="text" placeholder="city">
        <input id="c2"type="text" placeholder="city">
        <input id="c3"type="text" placeholder="city">
        <input id="c4"type="text" placeholder="city">
        <input id="c5"type="text" placeholder="city">
        <input id="c6"type="text" placeholder="city"><br>
        <input id="r1"type="text" placeholder="Region in city">
        <input id="r2"type="text" placeholder="Region in city">
        <input id="r3"type="text" placeholder="Region in city">
        <input id="cn1"type="text" placeholder="country">
        <input id="cn2"type="text" placeholder="country">
        <input id="cn3"type="text" placeholder="country">
        <input id="l1"type="text" placeholder="Latitude in degrees">
        <input id="l2"type="text" placeholder="Longitude in degrees">
        <button id="x" onclick="ab()">Click Me</button>
    </body>
</html>

please tell how could i find that which textbox is empty and which are filled when i click button click me

Hi,

Welcome to the forums :slight_smile:

You can do it like this:

document.getElementById("x");

x.onclick = function(){
  var inputs = document.getElementsByTagName("input");
    for (var i = 0; i < inputs.length; ++i) {
        if(inputs[i].value === ""){
           console.log("This input is empty");
        } else {
           console.log(inputs[i].value);   
        }
    }
}

fiddle

where should i place this code??

and where should i see the results??

i am using netbeans as ide on ubuntu machine…

sir nothing happens on clicking button x;;

Well, logging any values entered to the console was just by way of an example.
You can access the console by pressing F12 in your browser (usually), then selecting “Console”

Other than that, I have updated my demo to add a class to any inputs that didn’t contain values.
New demo