I cant get the value , help!

I cant get the value , help!
0

#1

var firstName = document.getElementById(‘firstName’).value;
var lastName = document.getElementById(‘lastName’).value;
var mobil = document.getElementById(‘mobil’).value;
var mejl = document.getElementById(‘mejl’).value;
var pushFormInfo = [];
function submitClicked(){
if (firstName, lastName, mobil, mejl === “”){
pushFormInfo.push(firstName,lastName, mobil, mejl);

i cant get the value when the user types in something in the form field, i just get “” “” “” “” ( the length).


#2

You can’t check multiple variables like this. You will have to check all of them individually.

EDIT:
Or do something fancy like:

if([x,y,z].indexOf("") < 0){
 console.log("x, y and z not empty!");
}

#4

https://codepen.io/MikeDaikSaik/pen/OxaJqP check! now it adds only ,


#5

Still doenst work :confused:


#6

You only take the value of the inputs when the page loads. You should check the inputs when the form is submitted.