Possibilities input mask with lib jquery

0

I am using input-maks to put a mask in the field but I am having difficulty setting a value, for example in my mask I put

'data-mask'=>"00000,00"
 referente ao campo decimal(5,2);

But if I want to put cents like 50 , I need to make 00000.50. Another example if I want to put 25.99 I need to put 00025.99. If I force put the comma before the field by default delete and do not let me write.

I'm using blade to create the text field

{{ Form::text( 'VAL_ESTOQ_PRODU', null,['class' => 'form-control input-mask', 'data-mask'=>"00000,00", 'placeholder'=>"00000,00", 'maxlength'=>"8", 'autocomplete'=>"off" ]) }}

How can I resolve this?

The puglin I'm using was made by:

 /**
 * jquery.mask.js
 * @version: v1.5.3
 * @author: Igor Escobar
 *
 * Created by Igor Escobar on 2012-03-10. Please report any bug at http://blog.igorescobar.com
 *
 * Copyright (c) 2012 Igor Escobar http://blog.igorescobar.com
 *
 **/
    
asked by anonymous 01.02.2017 / 01:59

1 answer

1

I think you just need to set the mask to reverse, passing the object {reverse: true} to the second parameter.

$(function () {
  $('#price').mask('00000,00', {reverse: true});
  $('#price').keyup(function () {
    $('#flash').html($('#price').val());
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.9/jquery.mask.js"></script>

<input name="price" id="price" type="text" />
<div>Preço: R$ <span id="flash">0,00</span></div>
  

Press Run and see the code working.

Using HTML notation, to set the mask as reverse, simply add the data-mask-reverse="true" attribute. So with Blade, I think it would look something like:

{{ Form::text( 'VAL_ESTOQ_PRODU', null,['class' => 'form-control input-mask', 'data-mask'=>"00000,00", 'data-mask-reverse'=>"true", 'placeholder'=>"00000,00", 'maxlength'=>"8", 'autocomplete'=>"off" ]) }}
    
03.02.2017 / 23:39