Jefferson Vasconcelos Jefferson Vasconcelos - 1 year ago 69
Javascript Question

While typing in a text input field, print content replacing dots

I need rewrite the content of some input into another using 'onkeyup' and replacing the '.' (dots) os the values. Right now, just onkeyup feature of my code runs. How can I do for delivery a 'clear' string (without dots) to another input?

My code:

<script type="text/javascript">
var minValue = $('money-min-value');

minValue.onkeyup = function(){
var clearMinValue = '';
clearMinValue = minValue.replace(/[^a-zA-Z 0-9]+/g,'');
$('meta_property_sell_price1').value = clearMinValue;

Answer Source

Does it fix?

jQuery(document).ready(function($) {

  $('#money-min-value').on('keyup',function() {
    var clearMinValue = '';
    clearMinValue = $(this).val().replace(/[^a-zA-Z 0-9]+/g, '');
<script src=""></script>
<label>#money-min-value <input type="text" id="money-min-value" ></label><br>
<label>#meta_property_sell_price1 <input type="text" id="meta_property_sell_price1" ></label>