javascript - CSS Button doesn't execute form when 'enter' pressed on keyboard -
i have form has css button.
i can submit form if click submit mouse, how can submit form if hit 'enter' key on desktop computer.
if hit 'enter' key nothing happens , form not submit.
thanks
<form action="login.php" id="login" class="iform" method="post"> <input type="text" class="inputs" placeholder="username / email" name="username" value="<?= $_cookie["loginreminder"]?>"/> <br /><br /> <input type="password" name="password" class="inputs" placeholder="password" /> <br /><br /> <input type="checkbox" name="keep" id="1" class="css-checkbox" /><label for="1" class="css-label">keep me logged in</label> <br><br> <input type='hidden' name='backtopage' value='<?= $sendback ?>'> <input type='hidden' name='submitbutt' value='login'> <a href="#" onclick="document.getelementbyid('login').submit();" class="button-big"> log in</a> </form>
you're using <a href=...
, javascript submit form, browser doesn't know submit action should be.
change
<input type="submit" value="log in" />
or
<button type="submit">log in<button>
for enter key work automatically.
using <button></button>
or <input type="submit" />
helps accessibility too.
Comments
Post a Comment