bkook / bkmoneykit Goto Github PK
View Code? Open in Web Editor NEWiOS UI controls and formatters for entering money, credit card number and expiry date.
License: MIT License
iOS UI controls and formatters for entering money, credit card number and expiry date.
License: MIT License
Please check this situation since this returns invalid dates.
Expiration dates in credit card is in gregorian calendar.
To replicate just change the calendar in the settings to Japanese for example.
BKCurrencyTextField
I'm trying to format the credit card number without setting the textfield class with BKCardNumberField. So I have typed this
let bkcardNumberFormatter = BKCardNumberFormatter()
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
textField.text = bkcardNumberFormatter.formattedStringFromRawString(newString)
return true
}
it is formatting but it is adding one more character in the end and can't delete text after whitespace. So please could you help me with it?
I really miss UITextFieldTextDidChangeNotification
. :)
Since shouldChangeCharacters
always returns NO
, it would be great to add a manual notification.
[[NSNotificationCenter defaultCenter] postNotificationName:UITextFieldTextDidChangeNotification object:self];
Hi, how we can change BKCurrencyTextField formats, for ex: 44.333 like this one, or enable only integer types: 44,000 ?
If you have a blank BKCurrencyTextField and you try and type or paste a letter character rather than a number character it crashes the app.
Here's the error:
2016-03-16 15:34:32.494 Alder[68142:1267089] *** Terminating app due to uncaught exception 'NSDecimalNumberOverflowException', reason: 'NSDecimalNumber overflow exception'
0 CoreFoundation 0x0000000107d54e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001077cddeb objc_exception_throw + 48
2 CoreFoundation 0x0000000107d54d9d +[NSException raise:format:] + 205
3 Foundation 0x000000010747db48 -[NSDecimalNumberHandler exceptionDuringOperation:error:leftOperand:rightOperand:] + 193
4 Foundation 0x000000010747c976 _checkErrorAndRound + 65
5 Foundation 0x000000010747cd46 -[NSDecimalNumber decimalNumberByDividingBy:withBehavior:] + 159
6 BKMoneyKit 0x00000001062e06ba -[BKCurrencyTextField textField:shouldChangeCharactersInRange:replacementString:] + 1370
I added BKMokeyKit with help cocoapods. And when I try compile my project I have error:
BKMoneyKit/BKForwardingTextField.m:15:1: Cannot synthesize weak property because the current deployment target does not support weak references
If I change Deployment Target in BKMoneyKit my project will compile.
Cocoapods version is 1.1.0
Can you add a podspec so this class can be used with CocoaPods?
Tapping numbers too quickly in BKNumberField breaks formatting and is not recoverable unless the view is reloaded. I believe it's due to cardPatternInfo not being properly instantiated fast enough. We end up with BKCardNumberFormatter.cardPatternInfoWithNumberString returning nil and setting self.cachedPrefix and self.cardPatternInfo to nil. This then never recovers. I can try to find a solution, but don't have time at the moment. Just wanted to point it out for now.
If i set the card number programatically it doesn't update the card logo. It only updates when you set the card number via writing it directly from keyboard.
The following case does NOT work:
self.cardNumberField.text = numberOfCard
It updates the text in the field but it does NOT update the card logo, how can I do to make the card logo load in this case where I set the card number programatically ?
Hi, thanks for sharing this great library.
I have problem with maximum fraction digits, when this number is equal to 3.
for ex in BKCurrencyTextField.m file:
_numberFormatter = [[NSNumberFormatter alloc] init];
_numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
[_numberFormatter setMaximumFractionDigits:3];
[_numberFormatter setCurrencyCode:@"KGS"];
[_numberFormatter setCurrencySymbol:@""];
[_numberFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"ru_RU"]];
_nonNumericRegularExpression = [BKMoneyUtils nonNumericRegularExpression];
_numberCharacterSet = [BKMoneyUtils numberCharacterSet];
self.placeholder = [_numberFormatter stringFromNumber:@(0)];
in this case if press any number, for ex 9, then press 0(zero) nothing changes.
Another words when setMaximumFractionDigits:2 everything is ok, but when 3 there is a problem.
Mastercard is releasing new cards that use BINs ranging from 222100-272099. Currently, this does not work with the current card patterns.
Source:
https://www.mastercard.us/en-us/issuers/get-support/2-series-bin-expansion.html
https://www.realexpayments.com/blog/mastercard-to-introduce-new-card-numbers/
Hello,
can you please submit a new cocoapods release?
Thanks,
Dem
Hi guys, congratulation so far!
Validation Methods:
I just wanted to tell you to if you can add a method which return a boolean if the credit card number, expiration date and cvv is in a valid format. I created it subclassing your class but would be better if you can add it directly in your code ;) Here the code:
func isValidCCNumber() -> Bool {
let ccNumberRegex = "^(([0-9]{4})[-|\\s| ]([0-9]{4})[-|\\s| ]([0-9]{4})[-|\\s| ]([0-9]{4}))|(([0-9]{4})[-|\\s| ]([0-9]{6})[-|\\s| ]([0-9]{5}))"
let ccNumberPredicate = NSPredicate(format:"SELF MATCHES %@", ccNumberRegex)
return ccNumberPredicate.evaluateWithObject(self.text!)
}
func isValidCCEpirationDate() -> Bool {
let ccExpirationDateRegex = "(?:0[1-9]|1[0-2])\\/2[0-9]{3}"
let ccExpirationDatePredicate = NSPredicate(format:"SELF MATCHES %@", ccExpirationDateRegex)
return ccExpirationDatePredicate.evaluateWithObject(self.text!)
}
func isValidCCCvv() -> Bool {
let ccCvvRegex = "^([0-9]{3,4})$"
let ccCvvPredicate = NSPredicate(format:"SELF MATCHES %@", ccCvvRegex)
return ccCvvPredicate.evaluateWithObject(self.text!)
}
Expiration Date Year Length:
In my app I need to use 4 digit number in the textfield but actually your code allow just 2. Would be better if you can let the user decide the length.
Separator Style:
In your app you automatically add the separation in the credit card number, which is an whitespace, and in the cvv, which is an " / ". Would be better if you can let the user decide them.
Hope you'll include them ;)
Cheers,
Carmelo
Is there any way to know when the card pattern was been completer to ask for MM//YY?
BKCurrencyTextField
crashes with a bluetooth keyboard connected if the user types a letter.
BKCurrencyTextField does not respect the horizontal text alignment set via storyboard
The code is breaking when you pop or dismiss the view controller which has bkmoneykit textfields. Can you please fix this asap?
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.