diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-08-31 14:53:08 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-08-31 14:53:08 +0200 |
| commit | 28b7ef196eaca6b9e455846cf6233bbabd9e4513 (patch) | |
| tree | eaf3fa41bed3a4988997587c865e2a6e1ceb45dd /StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js | |
| parent | 189eccc46edd09e78c9683580ccf078c28d5b34e (diff) | |
deploy android
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js')
| -rwxr-xr-x | StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js index 1c9540bc..9e0c49b6 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js @@ -38,9 +38,31 @@ var AddressView = SerializableView.extend({ validate_fields: function(data, errors){ if (this.disabled) { return } - if (this.checkPhone && ! data.Phone) { errors.push([ "Phone", "Please enter your phone number." ]) } - if (this.checkPhone && data.Phone && data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) } - if (! data.Province || data.Province == "NONE") { errors.push([ "Province", "Please choose your state." ]) } + if (this.checkPhone) { + var phone_number = data.Phone ? data.Phone.replace(/[^0-9]/g, "") : "" + var phone_length = phone_number.length + if (phone_length === 0 || ! data.Phone) { + errors.push([ "Phone", "Please enter your phone number." ]) + } + else if (phone_length < 10) { + errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number." ]) + } + else if (phone_length > 10) { + errors.push([ "Phone", "International phone numbers are not accepted." ]) + } + else if (data.Phone[0] === '+') { + errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ]) + } + else if (phone_number[0] === '1') { + errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ]) + } + } + if (! data.Province || data.Province == "NONE") { + errors.push([ "Province", "Please choose your state." ]) + } + if (data.ZipCode && data.ZipCode.length < 5) { + errors.push([ "ZipCode", "Please enter a valid zip code." ]) + } data.Address = data.Address1 + "\n" + data.Address2 data.UserId = auth.user_id delete data.Address1 |
