Skip to content

Commit

Permalink
fix: phone number input
Browse files Browse the repository at this point in the history
  • Loading branch information
tejaskh3 committed Oct 11, 2024
1 parent eb78191 commit cae16ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions app/constants/regex.js

This file was deleted.

8 changes: 5 additions & 3 deletions app/controllers/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { RDS_TWITTER, APPS } from '../constants/urls';
import { TOAST_OPTIONS } from '../constants/toast-options';
import { PHONE_REGEX, PHONE_NUMBER_CLEANUP_REGEX } from '../constants/regex';

export default class SubscribeController extends Controller {
@service login;
Expand All @@ -31,7 +30,7 @@ export default class SubscribeController extends Controller {
}
get isSubmitDisabled() {
return !this.email || (this.phone && !PHONE_REGEX.test(this.phone));
return !this.email || (this.phone && !/^\+?\d*$/.test(this.phone));
}
@action
Expand All @@ -47,7 +46,10 @@ export default class SubscribeController extends Controller {
@action
updatePhone(event) {
const input = event.target.value;
this.phone = input.replace(PHONE_NUMBER_CLEANUP_REGEX, '');
const isValidPhone = /^\+?\d*$/.test(input);
if (isValidPhone) {
this.phone = input;
}
}
@action
Expand Down

0 comments on commit cae16ba

Please sign in to comment.