<sjg:gridColumn name="orderLowPrice" title="Oder Low price" sortable="false" editable="true" edittype="text"/>
The above has to be a 7,4 decimal number basically with 3 digit max number and 4 decimal places.
how to set this rule in the grid column?
I do not have the libraries loaded, but JavaScript has some basic numeric formatting in place. use toPrecision(7) or toFixed(4) to obtain your desired results.
toPrecision(7) will only show 7 digits total (truncating if necessary)
toFixed(4) will only truncate the decimal to 4 digits.
I believe you can use formatter="formatNumber" in your column markup, and then the format function that it calls:
<sjg:gridColumn name="orderLowPrice"
title="Oder Low price"
sortable="false"
editable="true"
edittype="text"
formatter="formatNumber" />
...
<script>
function formatNumber(number){
return number.toFixed(4);
}
</script>
you can also reference here for more formatting information: https://code.google.com/p/struts2-jquery/wiki/FormatGrid
Related
I try to limit input number value to 2 decimal places by using decimal pipe.
<input [ngModel]="il.unitPrice | number:'1.2-2'" [ngModelOptions]="{updateOn: 'blur'}" (ngModelChange)="updateAmount($event,i)"
class="form-control text-right" type="text" name="unitPrice{{i}}"/>
It works sometimes. But in most cases, the decimal pipe doesn't get fired.
for example, when there is no values in the input field, I type '100'. It works. The value is converted to '100.00'. If I change the input '100.00' back to '100'. I expect the value to become '100.00' again, but nothing happened.
Another case is '100.0012'. The decimal pipe doesn't get fired either.
Is there anything wrong in above codes? How to use decimal pipe correctly?
Thank you very much in advance for your help.
To get the numbers with decimal characters in keyboard of iOS, I tried almost every trick in js and jquery (tel as input type, 0.01 as step etc...) but the only solution was the plugins:
https://github.com/mrchandoo/cordova-plugin-decimal-keyboard
https://github.com/gbrits/cordova-plugin-ios-decimal-keyboard
https://www.npmjs.com/package/cordova-plugin-decimal-keyboard-wkwebview
...
They are all working. However...
If there are more than one input fields after each other and if you switch from a "non-decimal" field to our "decimal" input field (either by arrows or by just tapping with fingers), you don't see the decimal character anymore, but just the numbers. If you unclick/click on "Done" and select the decimal input field again, it works then again.
This is the common problem of all the plugins. I'm asking myself whether it is a known issue or it is a very specific problem of my case?
This is my html:
<input v-if="isIOS" type="text" pattern="[0-9]*" decimal="true" decimal-char=","
maxlength="10" min="0" :max="detailsSelectedPunt.tMax" placeholder="Punt..." v-model="detailsSelectedPunt.Number">
<input type="text" maxlength="255" placeholder="Commentaar..." v-model="detailsSelectedPunt.Commentaar">
How to restrict user can allow to enter only 5 numbers before decimal and 2 numbers after decimal in textbox, like (99999.99).
use type is number, with maximum value and stepsize
<input type="number" min="1" max="100000" step="0.01">
I need a PrimeFaces input component, to get/set an amount of cash, that means a Decimal with 2 digits after the floating point.
I tried using inputMask, like
<p:inputMask value="#{moneyBean.amount}" mask="999.99"/>
But I can't find some way to set a mask that accepts:
1 or more arithmetic values before floating point
Optionally, a floating point "."
0 to 2 arithmetic values after the floating point
For Example, some valid inputs would be:
1234.56
1234.5
2.8
120
120.00
Any ideas to get this input in an efficient way?
A regular expression was the best way I've found so far
<p:inputText id="numInput" value="#{val.value}" required="true"
label="#{val.title}" validatorMessage="Not valid Number">
<p:ajax event="change" process="#form" update=":edit_main" />
<f:validateRegex pattern="^[-+]?[0-9]*\.?[0-9]{1,2}+$" />
</p:inputText>
<p:message for="numInput" />
you can use Client Side Validation tag visit link
http://www.primefaces.org/showcase/ui/csvEvent.jsf
There are so may example that can help you.
i think your problem will be resolved by these two tag
<f:validateDoubleRange minimum="5.5" maximum="8.5" />
and
<p:clientValidator />
tell if not work.
Now i got exactly what you want. you want only two digit after "."
The Prime Faces extensions are provide such type of checks.
Go throw the link
http://www.primefaces.org/showcase-ext/sections/inputNumber/advanceUsage.jsf
it will sure help you.
I have an input for telephone number.
I would like to write this format: 0175 6565 6262 (with spaces). But if write with " " spaces so get error and I write without spaces so get not error.
Here my HTML Input:
<input type="text" data-parsley-minlength="6" data-parsley-minlength-message="minlength six number" data-parsley-type="digits" data-parsley-type-message="only numbers" class="input_text" value="">
Hope someone can help me?
That's a great answer, but it's a bit too narrow for my needs. Input field should be tolerant of all potential inputs – periods, hyphens, parentheses, spaces in unexpected places, plus signs for international folk – and using this document from Microsoft detailing what numbers IE11 should accept, I've come up with this:
data-parsley-pattern="^[\d\+\-\.\(\)\/\s]*$"
Every number in that list passes the test with flying colours. Enjoy!
If you want your input to accept a string like "nnnn nnnn nnnn" you should use a regular expression.
For example, you can use the following HTML:
<input type="text" name="phone" value="" data-parsley-pattern="^\d{4} \d{4} \d{4}$" />
With this pattern the input will only be valid when you have fourdigits«space»fourdigits«space»fourdigits
You can test or tweak the regular expression and test it here: http://regexpal.com/
If you will use this pattern multiple times in your project I suggest you create a custom validator (see http://parsleyjs.org/doc/index.html#psly-validators-craft)