I have a simple input form.
<div id="inputboxforemailandpassword">
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
</div>
<hr>
<div id="apistatusmessage">
<p>loading...</p>
</div>
<button id = "buttonregister" class="btn btn-lg btn-primary btn-block" onclick="registration()" >
register
</button>
<button id = "clearinput" class="btn btn-lg btn-primary btn-block" onclick="clearouttheinputboxes()" >
clearinput
</button>
and this is the clear function i am using.
function clearouttheinputboxes()
{
var logopener="----entering clearouttheinputboxes----";
console.log(logopener);
//collect the email address and password.
var emailaddress = document.getElementById("inputEmail");
var password = document.getElementById("inputPassword");
emailaddress.setAttribute('value', "");
password.setAttribute('value', "");
var logcloser="----leaving clearouttheinputboxes----";
console.log(logcloser);
}
I have replicated this on my codepen, here.
https://codepen.io/jay-pancodu/pen/oNbVrVV
The issue is this.
a) on codepen, the exact same code, clears the input box just fine. b) on my web app, the input boxes remain, no matter how many times i try to clear and whichever value I use in the value.
So, what am I doing wrong here.
Update 1 - Lot of comments suggesting I use something like this
password.value = "some value";
that does not solve the problem for me. please check that I am getting the output in codepen. dont want to use .value method.
Update 2 - It looks like CodePen code does not work either
Update 3 - Recreating the issue on CodePen
able to set and clear input boxes before anything is typed. but once you type in the boxes, the ability to set and clear values is lost