Parsley.js Override Default Type Mapping - parsley.js

I have a series of fields where they need to be validated as a number, not as an integer. I've tried a number of different methods to change the constraint from integer to number, but none seem to stick. I've resorted to modifying the parsley.js source to map type="number" to the number validator, not the integer validator. There has to be another way other than modifying the library source code. The fields need to be type="number" to ensure the numeric keyboard is default, but they are NOT integers, but numbers with decimals.
Below is an example field
<input type="number" id="intimes-hobbs" data-parsley-type="number" value="" placeholder="Hobbs" required>

Related

ng-minlength less than a whole number

I'm using the code below in an application:
<input type="text" class="form-control" ng-model="waste.Quantity" ng-required="true" ng-minlength="1" ng-pattern="/^([1-9]*[1-9][0-9]*)$/" />
As you can see I have validation set on minimum length 1
Unfortunately for me customers need to enter decimals i.e. 0.5 NOT just whole numbers.
Is it possible to validate so anything equal or over 0.1 is passed?
Many thanks in advance.
ng-minlenght restricts the number of characters not the actual value, ng-pattern is your problem it's validating to accept only integers. something like /^[0-9]+\.?[0-9]*$/ would accept decimals

angularjs: taking only numbers (which are upto 10 char length)

I am developing first time in angular and my requirement is the input should take only digits up to length 10.
After lot of searches I know that I can either use input type as number which will restrict only numbers but the issue with this is it allows e character as exponential sigh and - sign for the math numbers. I do not want this. What I need is the text area should only allow numbers up to length 10 chars.
Hence I am using input type as text like below:
in my component template I defined something like below:
$
<div class="number">
<input type="text" formControlName="Q4a" maxlength="10" ng-
pattern="onlyNumbers" required /><!"/^[0-9]{1,7}$" ---->
</div>
onlyNumbers = '/^\d+$/';
$
but this does not work. The max length allowed is 10 chars but it does allow characters.
How do I achieve what I need, which is an input area that allows only digits up to 10 characters?

How to limit the number of digits in react-currency-input

I am trying to allow limited number of digits in my react-currency-input component. Below is my code to generate the currency input, which is working fine. but it is allowing unlimited number of digits in it. Could some one please help me to allow only a limited number of digits?
<CurrencyInput
value=""
prefix="$"
precision="2"
ref="myinput"
onChangeEvent={this.handleChangeEvent}
/>
You can specify maxLength for the input (the length includes prefix etc so take that into account):
<CurrencyInput maxLength={10} />

How to make input text field to accept only specific special character - angularjs

I want to restrict the input text field to accept only specific special characters and also the special character should not be the first character.
I have tried but could not able to find a solution for this problem.
<input type="text" ng-model="model.value" required="required" ng-pattern="/^[a-zA-Z0-9]+[^]*$/"/>
Given your attempt, I believe you want only A-Z, a-z and 0-9 for the first character, and after that, you want all characters except A-Z, a-z and 0-9.
The regex/ng-pattern for this is ^[a-zA-Z\d]+[^a-zA-Z\d]*$
So the field will be
<input type="text" ng-model="inputField" required="required" ng-pattern="/^[a-zA-Z\d]+[^a-zA-Z\d]*$/"/>

Does parsley.js support type="number" fields that have leading zeros, like zip code?

We have a zip code field. Right now we have it as type="text", but that means that phones don't use the numeric keypad. But before, when we had it as a type="number" the leading zeros would disappear - I think because of Parsley.js. Does this sound right? Is there a parsley.js option that allows us to use the number type without removing leading zeros?
I am using type="tel" plus a pattern.
It's not because of Parsley, it's because of the spec.
Use type=tel and pattern="-?\d+"

Resources