- I created a form, and a disabled button using the
disabled
attribute in the HTML file - ...then I created a JS file, to make the button enabled when all the input fields (4) are filled with text (doesn't matter how many letters.. so I am not going to use
.length
and an operator bec again, it does not matter to me..) all that matters to me, is that the button is enabled as long as all the input fields are filled with data. or else, it stays disabled.
this is what I did so far.. and what it does, is when one of the inputs is filled with any text, it enables the button and disables it back when the user goes on to another input field.. why? what am I doing wrong here?
any help would be very appreciated
const input = document.getElementsByClassName('.fillform')
input = addEventListener('keyup', e => {
if (e.target.value == "") {
document.getElementById('submitBtn').disabled = true;
} else {
document.getElementById('submitBtn').disabled = false;
}
});
<div class="container">
<form action="https://formspree.io/f/myyvwpgn" method="post">
<h1>Contact Me</h1>
<div class="rowOne">
<div class="col">
<div class="inputbox">
<input id="fillform" type="text" name="" required="required" placeholder="Enter your First Name" />
<span class="text">First Name</span>
<span class="line"></span>
</div>
<div>
<input class="fillform" type="text" name="lastName" placeholder="Enter your Last Name" />
<span class="text">Last Name</span>
<span class="line"></span>
</div>
<div>
<input class="fillform" id="email" type="Email" name="Email" required="required" placeholder="Enter your Email" />
<span class="text">Email</span>
<span class="line"></span>
</div>
<div>
<input type="text" name="" placeholder="comments goes here" />
<span class="text">Comment</span>
<span class="line"></span>
<div>
<textarea required="required"> </textarea>
<span class="text">More info</span>
</div>
<div>
<button id="submitBtn" disabled type="submit">submit
</div>