I'm facing a bit of a challenge with this task. As a newcomer to JavaScript, I've set out on a quest to create a task list board where users can input tasks along with dates and times. The goal is for these entries to appear inside a photo using JavaScript upon submission. While I have successfully made the photo appear when clicking "Submit," I have encountered a couple of issues:
- Unfortunately, the text, date, and time do not display correctly inside the photo. Instead, it shows as "[object HTMLInputElement]."
- Even though I have marked the input fields for text, date, and time as "required" in the HTML, the form still submits without any validation occurring.
function dd(x) {
return document.getElementById(x);
}
let output = "";
function addTask() {
output = `<div><img src="/assets/images/notebg.png" alt="Sticky Note"></div>`
let mainDiv = dd("main-page").innerHTML += output
}
<main id="main-page">
<div class="myForm">
<form>
<input type="text" id="task" class="inputs" placeholder="Enter your task here" required>
<br>
<input type="date" id="date" class="inputs" placeholder="Enter the date here" required>
<br>
<input type="time" id="time" class="inputs" placeholder="Enter the time here" required>
<br>
<input class="btn btn-primary" type="submit" value="Submit" onclick="addTask()">
<input class="btn btn-warning" type="reset" value="Reset">
</form>
</div>
</main>
<div class="my-notes" id="myNotes">
<p id="newNotes"></p>
</div>