Allow to enter only 5 numbers before decimal in textbox - jquery-ui

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">

Related

Parameter error converting string to decimal

I don't know what I am missing but I am getting the " Failed to convert parameter value from a string to a decimal" when I am trying to INSERT data.
I have a Access database with a table that has decimal fields. I am using decimal field because I need to store a number
like xx.xx.
The field is set as:
Field size as Decimal
Precision as 4
Decimal places as 2
This is the parameter I am using. I have tried many ways I have found on internet search but none work.
.Parameters.Add(New System.Data.OleDb.OleDbParameter("#RateUnitRate1", System.Data.OleDb.OleDbType.Decimal, 4, CType(tbRateUnitRate1.Text.Trim, Decimal)))
I know the textbox has a potential decimal value because when I check it with,
Dim rate As Decimal If Not Decimal.TryParse(tbRateUnitRate1.Text, rate) Then MsgBox("Not a valid input") tbRateUnitRate5.Text = "" tbRateUnitRate5.Focus() Exit Sub End If rate = CType(tbRateUnitRate5.Text.Trim, Decimal) MsgBox(rate.ToString)
I get a value of 3.50.
What am is missing.

Limit input number value to 2 decimal places with a decimal pipe

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.

Decimal Keyboard not showing in iOS after switching fields

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">

sjg:gridcolumn edit rule for decimal number

<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

parsley.js telephone digits input validating with spaces

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)

Resources