Answers for "html javascript call function after pressing enter"

1

html javascript call function after pressing enter

var yourElement = document.getElementById("yourElement");
yourElement.addEventListener("keydown", function (e) {
    if (e.code === "Enter") {  //checks whether the pressed key is "Enter"
        validate(e);
    }
});

function validate(e) {
    var text = e.target.value;
    //validation of the input...
}
Posted by: Guest on April-23-2021

Code answers related to "html javascript call function after pressing enter"

Code answers related to "Javascript"

Browse Popular Code Answers by Language