Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

limit characters display javascript

var str = 'Some very long string';
if(str.length > 10) str = str.substring(0,10);
Comment

how to limit characters in number input js

function limit(element)
{
    var max_chars = 2;

    if(element.value.length > max_chars) {
        element.value = element.value.substr(0, max_chars);
    }
}


<!-- HTML -->
<input type="number" onkeydown="limit(this);" onkeyup="limit(this);">
Comment

PREVIOUS NEXT
Code Example
Javascript :: react include a polyfill webpack v5 
Javascript :: multiple value selected in select2 
Javascript :: jquery on checkbox change 
Javascript :: react native text input right 
Javascript :: remove # url vuejs 
Javascript :: moment js react 
Javascript :: javascript array concat spread operator 
Javascript :: flip a coin javascript 
Javascript :: jspdf attach image file 
Javascript :: react on focus out 
Javascript :: javascript enumerate with index 
Javascript :: javascript iterate over object keys and values 
Javascript :: how to edit website 
Javascript :: javascript button 
Javascript :: datatables dynamically hide columns 
Javascript :: jest mock react-redux hooks 
Javascript :: how to create a random number generator in javascript 
Javascript :: how to align text vertically center beside an image in react native 
Javascript :: uncaught TypeError: $.jajax is not a function 
Javascript :: E: Unable to locate package npm 
Javascript :: jQuery on right mouse click 
Javascript :: drupal 8 check if current page is node 
Javascript :: react is there a safe area view for android 
Javascript :: js addeventlistener hover 
Javascript :: input type password react native 
Javascript :: import typography react 
Javascript :: object keys javascript 
Javascript :: mui switch colours 
Javascript :: how to get enum item name in javascript 
Javascript :: regex not contains 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =