Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
Uncaught TypeError: Cannot read properties of null (reading 'value') fix

Good Day,

What I want the outcome to be:

When the user clicks on the add button it creates a new list

Issue I am having:

When I click the add button, I get an error stating that the value is null.

I have created a logic that if the input value is null there should be an alert.

HTML

<div class="form">
 <input class ="user-input" type="text">
 <input class="date" type="date">
 <input class="time" type="time">
 <button onclick="addTask()" class="add" id="add">+</button>
</div>

JS

// variables object

const el = {
  form: document.querySelector(".form"),
  input: document.querySelector(".user-input"),
  date: document.querySelector(".date"),
  time: document.querySelector(".time"),
  
};
//local storage key

const storage_key = "tasks-storage-key";

//Create ID

const createID = () => `${Math.floor(Math.random() * 10000)}-${new Date().getTime()}`

//variable of empty array that gets new task
let taskList =[];

// function that renders task list

//function that creates new tasks with date and time
function addTask() {

  const id = createID();
  const taskNew = el.input.value;
  const taskDate = el.date.value;
  const taskTime = el.time.value;

  if (taskNew != null) {

    const tasks = document.createElement("div");
    tasks.innerHTML = `
        <div class="task-content">
        <div class="list-of-task">
        <div class="id">${id}</div>
        <input type="checkbox" class="tick">
        <div class="new-task-created">${taskNew}</div>
        <label class="due-date">${taskDate}</label>
        <label class="due-time">${taskTime}</label>
    </div>

    <div class="atcion-buttons">
        <button class="edit" data-id="">Edit</button>
        <button class="delete" data-id="">Delete</button>
    </div>
</div>`

  };
  return taskNew
};

Image of Error

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!