Jquery and JSF - format masks for text fields

Asked

Viewed 153 times

0

Good evening, I’m doing a college job and I’m wearing shades for decimal fields in my text field, where I have to validate with an accuracy of 4 houses too much at most, I put a mask with the accuracy of 4, but in view of what has been asked he must also accept to fill the field with 1, 2, 3 decimal places, has some form of using putting the minimum and maximum precision in masked fields.

<f:facet name=“header”>
<h:outputLabel value="#{messages.conversion}"/>
</f:facet>
<h:inputText id=“fldConversion” value="#{row.vlConversion}" label="#{messages.conversion}"
maxLength=“18” disabled="#{defaultMBean.canDisabledConversion(row)}">

<a4j:ajax event=“change” immediate=“true” render="@all, partnerItem, dataModel"/>
<f:converter converterId=“javax.faces.BigDecimal”/>
<f:validateLength maximum=“19” />
</h:outputText>

And so I put in javascript.


jQuery(document).ready(function() {
// Configuração para campos de Real.
// Configuração para mudar a precisão da
máscara. Neste caso a máscara irá
// aceitar 4 dígitos após a virgula.
jQuery("#fldConversion").maskMoney({
showSymbol : false,
symbol : “false”,
decimal : “.”,
thousands : “.”,
precision : 4
});

Is there any way to make this mask pick up an accuracy of 1 to 5 decimal places in the mask, like a maximum and minimum value of decimal places?

1 answer

0


I made an example a little different from your most think that’s what you want, put so on your javascript:

$(document).ready(function() { $('#money').mask('#.##0,00', {reverse:true}); })

And in the HTML:

<input type="text" id="money" placeholder="Digite um valor"/>
  • Opa valeu worked, thank you very much.

  • The good that now does not look the same before stayed the times I wanted to play 1 decimal house of the interval 1 to 4, he only played a precision of 4 houses now I can play with 1 house that he accepts too.

  • If you solved your problem check the answer as solved " " helps new Stack Overflow users.

Browser other questions tagged

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