omarshammas / jquery.formance

A jQuery library for formatting and validating form fields, based on Stripe's jQuery.payment library.
omarshammas.github.io/formancejs
Other
632 stars 105 forks source link

Phone Number Issue #23

Closed Kcharle closed 8 years ago

Kcharle commented 9 years ago

Formatting of the phone number works properly, but once you have typed the full number in the validation does not work and it throws a console error.

Uncaught TypeError: Cannot read property '0' of null

http://prntscr.com/7szngj

mkaatman commented 9 years ago

I don't know how to fix it in the coffee source, but here is one way to correct for the javascript output.

The third line trims the length before doing validation. If you validate without trimming the regex returns null and the code breaks.

~line 1243 reFormatPhoneNumber = function(phoneNumberString) { var areaCode, first3, last4, phoneNumber, text, _ref; phoneNumberString = phoneNumberString.substring(0, 16);