Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react prevent form submission on enter key press inside inputs

    // Prevent form submission on enter key press inside inputs
    const listener = e => {if(e.keyIdentifier==='U+000A'||e.keyIdentifier==='Enter'||e.keyCode===13){if(e.target.nodeName === 'INPUT' && e.target.type !== 'textarea'){e.preventDefault();return false;}}};
    document.addEventListener('keydown', listener, true);
Comment

PREVIOUS NEXT
Code Example
Javascript :: editting collection in firebase firestore 
Javascript :: Conflicting peer dependency: react@18.0.0 npm WARN node_modules/react 
Javascript :: react pass parameters to other page 
Javascript :: how to remove an class in javascript 
Javascript :: javascript increment by 1 
Javascript :: react context 
Javascript :: what is div in javascript 
Javascript :: using html forms to define javascript variables 
Javascript :: merge sort javascript 
Javascript :: start pm2 node process with flags 
Javascript :: date difference moment js 
Javascript :: link in directive angularjs 
Javascript :: js encode url 
Javascript :: convert an object to an array 
Javascript :: hide_node example jstree 
Javascript :: jquery: select select box rpogramatically 
Javascript :: angular new component 
Javascript :: js check if a variable is an array 
Javascript :: preventdefault not working form submit react 
Javascript :: js encryption 
Javascript :: two decimal places javascript 
Javascript :: get minutes and seconds from youtube seconds on js 
Javascript :: json object check if key exists java 
Javascript :: axios fainally 
Javascript :: js loop away backward 
Javascript :: “https://packagist.org/packages.json” file could not be downloaded: failed to open stream: Operation timed out 
Javascript :: request entity too large express 
Javascript :: check for string anagram javascript 
Javascript :: js parse url 
Javascript :: jquery 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =