Replace comma with dot when typing decimals in input - Javascript

How can I replace comma with dot when typing decimals in input field, by using javascript function ?
posted on 24.03.2020 at 18:15
0pnshow more

To replace comma with dot while typing or inserting of the number into input field, you can use Javascript solution with onKeyUp and onBlur event:

<script type="text/javascript">

function replaceComma(i) {
var val = document.getElementById(i).value;
if (val.match(/\,/)) {
val = val.replace(/\,/g, '.');


<input type='text' id='amount' onKeyUp="javascript: replaceComma('amount'); " onBlur="javascript: replaceComma('amount'); " />

posted on 27.03.2020 at 15:26
0pnshow more
share on facebookshare on twitter
2020 AnswerTabsTermsContact us
This site uses cookies to improve your experience, for analytics and ads. By continuing to browse this site you agree to our use of cookies.