i know the title is weird but let me explain what i'm trying to do.
I have a login form with two input fields a checkbox and a submit button. Here is a screenshot:
The terms of use is a popup through which the user can see the terms of use. My problem is that when a user clicks the checkbox and presses the enter button the popup is appeared again. My desire is when the user clicks the checkbox and press the enter button to go to his homepage. How to do this? Is there a way to overtake opening the popup with on enter?
You would use the keydown
event in conjunction with the checkbox and test for the ENTER key press;
document.querySelector("[type=checkbox]").addEventListener("keydown", function(evt){
if(evt.keyCode === 13){
console.log("you pressed ENTER");
window.location = "http://cnn.com";
}
});
<input type=checkbox> Click me and then press ENTER
Keep in mind that client side code is not secure and this can be bypassed by a user. All security type code should happen on a server.