How to submit data form without clicking a submit button
I’m trying to write a code to automatically log me into a particular website. I have successfully gotten it to enter the username/password credentials, but do not know how to get the form to then submit without me having to click the “submit” button. Is there someway to code the form to automatically submit my info (maybe by a JS function or by overwriting their html)? WEBSITE’S HTML: <form action="/home/signin?ReturnUrl=%2fappointments" method="post"> <fieldset> <div class="login-inner"> <input id="ReturnUrl" name="ReturnUrl" type="hidden" value="/appointments" /> <div class="input-container"> <span class="input-label"> <label for="Email">Email</label> </span> <input class="input" id="Email" name="Email" placeholder="Email or User Name" size="16" type="text" value="" /> </div> <div class="input-container"> <span class="input-label"> <label for="Password">Password</label> </span> <input class="input" id="Password" name="Password" placeholder="Password" size="16" type="password" /> </div> <div> <input type="submit" class="login" value="Log In" /> </div> My CODE SO FAR: var myUser = document.getElementById("Email"); myUser.value = "Username"; var myPass= document.getElementById("Password"); myPass.value = "Password"; https://code.sololearn.com/WGRX9sZ5icTK/?ref=app
11/7/2019 3:25:31 PMRandy
7 AnswersNew Answer
What you could do is use an onkeypress event in the input box, and run a function each time that checks if the username and password is correct, if so, login. This is the lightest way I can think of approaching this.
thanks Coder's Crux would onkeypress still work if im trying to import the login data automatically without typing it (and running it on a tablet or phone)? also, i just found these two html attributes online that sounded like they might do something similar to your idea of onkeypress: <input type="text" oninput="myFunction()"> <input type="text" onchange="myFunction()"> Could these be other viable options? and if so, how do i program them to work in the code? (I’m only a couple weeks into coding so dont know too much about all the ins and outs)
Coder's Crux hmm, thats a great start. Thanks so much!!!