如果不输入,converterconverter可以忽略$符号 [英] can currencyconverter ignore the $ sign when not entered
本文介绍了如果不输入,converterconverter可以忽略$符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在数据表中,我必须将输入验证为货币.在删除$符号后输入值时,输入组件将引发错误.
In a datatable, I have to validate the input as currency. When I enter the value after deleting the $ sign, the input component throws an error.
<p:column>
<f:facet name="header">
<p:outputLabel value="REC REVENUE" />
</f:facet>
<p:inputText id="RERVN" styleClass="RERVN"
value="#{segmentSetup.userSegmentTypesMap['RERVN'].segmentValues[rank].rangeMinValue}"
disabled="#{!segmentSetup.userSegmentTypesMap['RERVN'].selected || (rank==fn:length(segmentSetup.ranks)) }"
validator="#{segmentSetup.validateRanges}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="0" currencySymbol="$" type="currency" />
</p:inputText>
<p:message for="RERVN" />
</p:column>
当我输入不带美元符号的值时,会出现此验证错误.
When I enter a value without the dollar sign, I get this validation error.
推荐答案
将$
与输入分开,并使用常规数字转换器.
Put the $
apart from the input and use a normal number converter.
$<p:inputText ...>
<f:convertNumber maxFractionDigits="2" minFractionDigits="0" />
</p:inputText>
如有必要,您可以使用CSS将$直观地重新放置到input元素中.这是纯HTML/CSS中的启动示例:
You can if necessary use CSS to reposition the $ visually back into the input element. Here's a kickoff example in plain HTML/CSS:
<div class="currency"><span>$</span><input /></div>
使用
.currency span { position: absolute; margin: 5px 2px; }
.currency input { padding-left: 5px; }
这篇关于如果不输入,converterconverter可以忽略$符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文