Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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...
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #html #javascript #call #function #pressing #enter
ADD COMMENT
Topic
Name
4+6 =