I cant get the value , help!

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).

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

Or do something fancy like:

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

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

Still doenst work :confused:

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

1 Like