Possibilities input Mask with jquery lib

Asked

Viewed 592 times

0

I’m using the input-maks to put a mask on the field but I’m having the difficulty of 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 pennies like 50, I need to do 00000.50. Another example if I want to place 25.99 I need to place 00025.99. In case I force to put the comma before the field by default erases and don’t let me write.

I’m using blade for creation of 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 fix this ?

The puglin I’m wearing 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
 *
 **/
  • I have no idea what package you’re using, but it wouldn’t be just ,00 to Mask?

  • putting it only Usario ,99; then in case of doing 115,00 would not give

  • @gmsantos doesn’t really know which one I’m using, but if you understand what I want and want to indicate some

  • Your question is unclear, but it’s not related to Blade. I recommend editing your question along with the tags and searching on the lib in jquery q vc is using

1 answer

1

I believe that you just set the mask as reverse by passing the object {reverse: true} in 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>
<script src="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 Execute and see the code in operation.

Using HTML notation, to set the mask as reverse, simply add the attribute data-mask-reverse="true". Soon, with Blade, I believe 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" ]) }}
  • And to put the R$ in front ?

  • And how am I gonna get past the data-tag ?

  • Edited. What do you mean by "put R$ in front"? Display only in the mask or must be present in the current value of the input?

  • display only in the mask

  • Gave right here only this missing to get round the R $ in the mask in front of the value

  • I believe only by defining the mask as a Javascript function. It is not possible to just use HTML notation. You cannot insert these characters directly into the HTML before the input?

  • I’ll try here, but I think he’ll come down

  • If this Blade API returns the input HTML code, just do R$ {{ Form::text(...) }}. The input, by default is arranged online, so it will be perfectly aligned with the text, unless you styled it with CSS and changed the default behavior.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.