Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

input two decimal places javascript

//Force User Input to Two Decimal Places
//From https://stackoverflow.com/questions/46321683/javascript-restrict-input-once-2-decimal-places-have-been-reached

//HTML Code
<input type="text" oninput="validate(this)" />
  
//JavaScript Code
<script type="text/javascript">
var validate = function(e) {
  var t = e.value;
  e.value = (t.indexOf(".") >= 0) ? (t.substr(0, t.indexOf(".")) + t.substr(t.indexOf("."), 3)) : t;
}
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: base64 nodejs image 
Javascript :: unidirectional data flow react 
Javascript :: convert a string to number in javascript 
Javascript :: react conditional array item 
Javascript :: how to create a filelist object in javascript 
Javascript :: filter object by key name 
Javascript :: useref react 
Javascript :: empty input field on click 
Javascript :: Javascript stringify with functions 
Javascript :: round innerhtml up javascript 
Javascript :: js canvas draw image 
Javascript :: inline style react with true or false 
Javascript :: delete all the fields on the form whit jquery 
Javascript :: vue 3 router redirect 
Javascript :: how to flat an array in javascript iteratively 
Javascript :: use font awesome in react native 
Javascript :: open link in new tab javascript 
Javascript :: angular 6 key value pair getvalue example 
Javascript :: axios.filter 
Javascript :: dynamically added button onclick not working 
Javascript :: regex quantifiers 
Javascript :: javascript function uppercase to lowercase 
Javascript :: document.queryselector null check 
Javascript :: object key as variable 
Javascript :: catch javascript 
Javascript :: how to get last child element in javascript 
Javascript :: innertext of element js 
Javascript :: node get value from map 
Javascript :: how to delete a folder using node js 
Javascript :: jquery select all checkboxes except disabled 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =