Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to make HTML input tag only accept numerical values? in jsx

<input
      onKeyPress={(event) => {
        if (!/[0-9]/.test(event.key)) {
          event.preventDefault();
        }
      }}
    />
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #HTML #input #tag #accept #numerical #jsx
ADD COMMENT
Topic
Name
2+2 =