From a1be0e95b421934f4a6d91bb1f327b18cf20ba33 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 16 Apr 2018 10:10:25 +0100 Subject: [PATCH] remove the dead validation --- services/web/app/views/subscriptions/new.pug | 22 +++------ .../coffee/main/new-subscription.coffee | 46 ++++--------------- 2 files changed, 15 insertions(+), 53 deletions(-) diff --git a/services/web/app/views/subscriptions/new.pug b/services/web/app/views/subscriptions/new.pug index 27908d4c2c..5644710723 100644 --- a/services/web/app/views/subscriptions/new.pug +++ b/services/web/app/views/subscriptions/new.pug @@ -101,9 +101,8 @@ block content ng-model="data.last_name" required ) - span.input-feedback-message {{ simpleCCForm.lastName.$error.required ? 'This field is required' : '' }} - .form-group(ng-class="validation.correctCardNumber == false || validation.errorFields.number || inputHasError(simpleCCForm.ccNumber) ? 'has-error' : ''") + .form-group() label(for="card-no") #{translate("credit_card_number")} div#card-no( type="text" @@ -113,41 +112,36 @@ block content ng-blur="validateCardNumber();" required ) - span.input-feedback-message {{ simpleCCForm.ccNumber.$error.required ? 'This field is required' : 'Please re-check the card number' }} .row .col-xs-3 - .form-group.has-feedback(ng-class="validation.correctExpiry == false || validation.errorFields.expiry || inputHasError(simpleCCForm.expiry) ? 'has-error' : ''") + .form-group.has-feedback() label(for="month") #{translate("month")} div( - type="text" + type="number" name="month" ng-focus="validation.correctExpiry = true; validation.errorFields.expiry = false;" ng-blur="updateExpiry(); validateExpiry()" data-recurly="month" required ) - span.input-feedback-message {{ simpleCCForm.expiry.$error.required ? 'This field is required' : 'Please re-check the expiry date' }} .col-xs-3 - .form-group.has-feedback(ng-class="validation.correctExpiry == false || validation.errorFields.expiry || inputHasError(simpleCCForm.expiry) ? 'has-error' : ''") + .form-group.has-feedback() label(for="year") #{translate("year")} div( - type="text" + type="number" name="year" data-recurly="year" ng-focus="validation.correctExpiry = true; validation.errorFields.expiry = false;" ng-blur="updateExpiry(); validateExpiry()" required ) - span.input-feedback-message {{ simpleCCForm.expiry.$error.required ? 'This field is required' : 'Please re-check the expiry date' }} - - .col-xs-6 - .form-group.has-feedback(ng-class="validation.correctCvv == false || validation.errorFields.cvv || inputHasError(simpleCCForm.cvv) ? 'has-error' : ''") + .form-group.has-feedback() label #{translate("security_code")} div( - type="text" + type="number" ng-model="data.cvv" ng-focus="validation.correctCvv = true; validation.errorFields.cvv = false;" ng-blur="validateCvv()" @@ -164,9 +158,7 @@ block content tooltip-trigger="mouseenter" tooltip-append-to-body="true" ) ? - span.input-feedback-message {{ simpleCCForm.cvv.$error.required ? 'This field is required' : 'Please re-check the security code' }} - div .form-group(ng-class="validation.errorFields.country || inputHasError(simpleCCForm.country) ? 'has-error' : ''") label(for="country") #{translate('country')} diff --git a/services/web/public/coffee/main/new-subscription.coffee b/services/web/public/coffee/main/new-subscription.coffee index e5e0165163..ab1128ed33 100644 --- a/services/web/public/coffee/main/new-subscription.coffee +++ b/services/web/public/coffee/main/new-subscription.coffee @@ -21,10 +21,6 @@ define [ value: "credit_card" $scope.data = - number: "" - month: "" - year: "" - cvv: "" first_name: "" last_name: "" postal_code: "" @@ -34,12 +30,8 @@ define [ city:"" country:window.countryCode coupon: window.couponCode - mmYY: "" - - $scope.validation = - correctCardNumber : true - correctExpiry: true - correctCvv: true + + $scope.validation = {} $scope.processing = false @@ -49,13 +41,14 @@ define [ all: fontFamily: '"Open Sans", sans-serif', fontSize: '16px', + fontColor: '#7a7a7a' month: - placeholder: 'mm' + placeholder: 'MM' year: - placeholder: 'yy' + placeholder: 'YY' cvv: - placeholder: 'cvv' - + placeholder: 'CVV' + pricing = recurly.Pricing() window.pricing = pricing @@ -97,26 +90,6 @@ define [ $scope.currencyCode = newCurrency pricing.currency(newCurrency).done() - $scope.updateExpiry = () -> - parsedDateObj = ccUtils.parseExpiry $scope.data.mmYY - if parsedDateObj? - $scope.data.month = parsedDateObj.month - $scope.data.year = parsedDateObj.year - - $scope.validateCardNumber = validateCardNumber = -> - $scope.validation.errorFields = {} - if $scope.data.number?.length != 0 - $scope.validation.correctCardNumber = recurly.validate.cardNumber($scope.data.number) - - $scope.validateExpiry = validateExpiry = -> - $scope.validation.errorFields = {} - if $scope.data.month?.length != 0 and $scope.data.year?.length != 0 - $scope.validation.correctExpiry = recurly.validate.expiry($scope.data.month, $scope.data.year) - - $scope.validateCvv = validateCvv = -> - $scope.validation.errorFields = {} - if $scope.data.cvv?.length != 0 - $scope.validation.correctCvv = recurly.validate.cvv($scope.data.cvv) $scope.inputHasError = inputHasError = (formItem) -> if !formItem? @@ -128,10 +101,7 @@ define [ if $scope.paymentMethod.value == 'paypal' return $scope.data.country != "" else - return (form.$valid and - $scope.validation.correctCardNumber and - $scope.validation.correctExpiry and - $scope.validation.correctCvv) + return form.$valid $scope.updateCountry = -> pricing.address({country:$scope.data.country}).done()