I have some code as below (work fine)
<pe:inputNumber
value="#{myBean.myVal}"
minValue="0" maxValue="999999999999999.999999999"
emptyValue="1"
thousandSeparator="."
decimalSeparator=","
/>
then, if i enter [1] it will show [1,000000000], my trouble is alot of zero maybe confuse my user.
Is there anyway to trim it on this input ?, just display whatever user entered such as [1,20] -> [1,2] or [1,20]
my script :
function trimDecimalPlace(){
var curVal = $(".ui-inputNum > input:first-child").val();
var parseVal = '';
if(curVal.indexOf(".") > curVal.indexOf(",")){
var tokens = curVal.split(".");
var decimalVal = parseFloat("0."+tokens[1])+"";
if(decimalVal != "0"){
parseVal = tokens[0]+"."+decimalVal.substring(2);
}else{
parseVal = tokens[0];
}
}else{
var tokens = curVal.split(",");
var decimalVal = parseFloat("0."+tokens[1])+"";
if(decimalVal != "0"){
parseVal = tokens[0]+","+decimalVal.substring(2);
}else{
parseVal = tokens[0];
}
}
$(".ui-inputNum > input:first-child").val(parseVal);
}
and call it on blur:
<pe:inputNumber
value="#{myBean.myVal}"
minValue="0" maxValue="999999999999999.999999999"
emptyValue="1"
onblur="trimDecimalPlace();"
thousandSeparator="."
decimalSeparator=","
/>