Question: I'm trying to create a function that will check to make sure all the input a user provided is numeric.

```
function wholeFormValid() {
var inp = document.getElementsByClassName('userInput'); 
    //userInput is a class name i provide to all my non-hidden input fields.
    //I have over 20 hidden values (I need to use hidden values to store state in a session).

    //Wanted to print out what my function is getting. I keep seeing undefined values.
var string= "justToInitializeThis";
for(var m in inp) {
    string = string + " " + inp.value;
}
alert(string);

    //Actual function that will be used once I track down the bug.
for(var i in inp) {

    if(inp.value != "") {
        if(!(/^[0-9]+$/.test(inp.value))) {
            return false;
        }
    }
}
return true;

```

}

The function does get the right input fields back, I can tell from my different pages and they vary in the amount of input a user can give. But what i can't understand is why all my values are returned as null instead of what the user entered. I'm fairly new to HTML & Javascript and just needed a second pair of eyes on this :) Thanks in Advance.

Answer: 
Use this

```
var inp = document.getElementsByClassName('userInput'); 

var string= "justToInitializeThis";
for(var i=0; i < inp.length; i++) {
    string = string + " " + inp[i].value;
}
alert(string);

```

Same for another loop too
***Change:***

```
for(var m in inp) {
    string = string + " " + inp.value;
}

```

***To:***

```
for(var m in inp) {
    string = string + " " + inp[m].value;
}

```

> 
> A for ... in loop iterates over the properties of an object
> 
> 
> 

<https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in>