fcsamerica / angular-fcsa-number Goto Github PK
View Code? Open in Web Editor NEWAn Angular directive that validates numbers and adds commas as thousand separators.
License: Apache License 2.0
An Angular directive that validates numbers and adds commas as thousand separators.
License: Apache License 2.0
Angular 2 is out. What is the possibility of having an ng2 version of this directive?
Thanks.
I have a use case where we don't want the user to enter in decimal values. We are using the following options:
fcsa-number="{ maxDecimals: 0, preventInvalidInput: true }
I would like for only numbers and commas to be allowed as input. However, I can still enter in a decimal value, I just get an error (red border). I'll see if I can throw a pull-request together for this, but wanted to submit this in case you had any ideas on built-in ways to achieve my use case.
If within an input field, the type is set to "number" as below, the form will be automatically emptied on blur if a number is entered that is greater than 999.
<input type="number" class="form-control" ng-model="payment" placeholder="100.00" required name="credit" fcsa-number="{min: 0, maxDecimals: 2}">
Problem scenario : We have product order form with Total field
. User can add more products and add price. So we are doing total using angular directive and update Total field.
But price field with fcsa number
directive value return undefined
.
any sample example to solve this issue? I am sure some of you may have already face & solved this problem :-)
thanks for support
Currently, you can still paste invalid characters into an input box when "preventInvalidInput: true".
Hi!
I found your component is very useful - thank you!
What I didn't understand is why model's type is changing.
For example: I have $scope.amount = 1234.00 but if I try to change the amount I will have new value of the $scope.amount as a string. I think model's value type should be the same.
http://plnkr.co/edit/VaA7gXG6yBeuOC2WaT0W?p=preview
On blur the decimal portion of an fcsa number is being formatted with commas. Ideally the formatter will only add comma separators to the integer portion of the number.
Current behavior:
1123.45678 is formatted to 1,123.45,678
Correct behavior:
1123.45678 should be formatted to 1,123.45678
Hi,
Despite the correct branch clone, I can't overide the default options for :
thousandsSeparator: '.',
decimalMark: ','
I'd like to put a space instead of '.' for the thousandsSeparator.
Thx for your help.
When using FCSA and ng-model-options="{ updateOn: 'blur' }"
the model is not updated. I believe it is related to this SO Post as well.
Presume there is a good reason why it wasn't done already.. but is it possible to apply formatting change as you type rather than only on losing focus?
When we input just a hyphen '-' it's still valid hence when submit, the model is binding with '-' which is wrong when posting to server.
Hello buddy ^_^,
I want to use this library for validate PIN,
so I don't need separator,
how to disable?
I don't know why.. but the model always returning me undefined..
<input type="text" fcsa-number="{ prepend: '$' }" class="form-control" placeholder="$(Maximum)" ng-model="investor.investment_range.max" />
I'm submitting a ...
[x] bug report
Current behavior
Fcssa-number is not working properly with ng-submit directive. Whenever I append or prepend anything using fcsa-number and submit the form it turns that field red and stores value in model as 'undefined'. It only shows this error on append or prepend without them it works fine.
Also if I remove ng-submit and use ng-click on submit button to call saveForm() function, it works fine while using prepend/append as well. It only shows error when using ng-submit directive
This is my code from a View.html
<form id="frmCostAndApproval" name="frmCostAndApproval" ng-submit=saveForm() novalidation>
<div class="form-group">
<label>Workup Sum Approved:</label>
<input type="text" fcsa-number="{ prepend: '$' , preventInvalidInput: true }" class="form-control" name="WorkupSumApproved" ng-model="costAndApprovals.WorkupSumApproved" autocomplete="off" />
</div>
<div class="form-group">
<label>AG2 Total Costs Approved:</label>
<input type="text" fcsa-number="{ preventInvalidInput: true }" class="form-control" name="AG2TotalCostApproved" ng-model="costAndApprovals.AG2TotalCostApproved" autocomplete="off" />
</div>
<button type="submit" class="btn btn-primary" ng-disabled="frmCostAndApproval.$pristine">
Submit
</button>
</form>
This is my code from a angular controller file ctrl-Cost&Approval.js
$scope.saveForm = function () {
$scope.isProcessing = true;
var item = angular.copy($scope.costAndApprovals);
console.log(item);
}
This is my console window output
object
WorkupSumApproved: undefined,
AG2TotalCostApproved: 545452
Please guide me what the issue is and provide your help to the earliest. Looking forward for a positive response. Thank you.
Expected/desired behavior
The fields with prepend/append should not be undefined when form is submitted using ng-submit directive of AngularJs
About my environment:
Thank you for making such a great Directive.
My issue:
My form is always dirty after it loads since the addition of commas changes the values. Is there any way to resolve this issue?
where i change the number format change. it's config or anybcode change
Hi all!
some time ago we used to use this lib in my company project. I have made a bunch of changes and pushed it to the npm. After short interval it turned out that we will be switching to self-made stuff.
here is the gist where all patches attached - https://gist.github.com/ZuBB/85cf9e4ba28fd10b053b
if you need access to npm package -- let me know
It would be really nice if you made this available as an npm package π
Great tool, thanks for providing.
Add ability to specify fraction size.
fcsa-number="{ fractionSize: 2 }"
100 formats like 100.00
100.1 formats like 100.10
Second feature request - support rounding method if user is allow to specify more then fractionSize.
I used this to create a currency field that prepended the "$" symbol. Everything worked well, but when I tried submitting the form it registered the field as invalid even though it was valid. Further testing showed that it tried to submit the "$" symbol along with the currency amount and I'm guessing this is why it considered the field as invalid. I tested this by prepending a number instead of a symbol and the form submitted fine but the submitted field value included the prepended number.
When using Kinoma to obtain the field value it strips off the prepended characters just fine, but it seems to have trouble doing this when the form is submitted.
I could not find any solution to this, so I went ahead and used the input-group feature from Bootstrap to add the currency symbol outside of the input field. However, it would be great to be able to submit forms using the prepend option from FCSA-Number in the future if possible.
because if must return a number returns a string?
It happens when the element is: <input type="text" fcsa-number />
check fcsaNumber.js line 121.
I suggest online 121:
return parseFloat(noCommasVal);
Thanks...
Hi,
If I enter a negative number in the component, the validation work correctly but if I value the variable ng-model from the controller, the validation is not working.
I'm using Chrome Latest on OSX Mavericks and both on your demo and in my app I've noticed that fields that have fcsa-number="{ preventInvalidInput: true }"
attached don't allow anything to be input β text or number.
This directive works great. However, it would be nice to be able to configure the separator character, since many European countries use a space instead of a comma
Currently, all errors result in "fcsa-number" being set to true in $errors in the ngModelController. It would be great to get some granularity on why certain errors occur such as:
I noticed that angular-fcsa-number is not allowing input with commas. You may want to consider allowing commas as a valid input. Iβm suggesting this because:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.