Fire an event on phone number validation
Fix a bug introduced by recent phone number input work that prevented the call and sms buttons from being clickable.
This commit is contained in:
parent
f6376c0fa2
commit
5d044bd00e
3 changed files with 6 additions and 3 deletions
|
@ -34,7 +34,7 @@
|
|||
} else {
|
||||
$('#choose-setup').show().addClass('in');
|
||||
|
||||
$('input.number').on('keyup', function() {
|
||||
$('input.number').on('validation', function() {
|
||||
if ($('#number-container').hasClass('valid')) {
|
||||
$('#request-sms, #request-voice').removeAttr('disabled');
|
||||
} else {
|
||||
|
|
|
@ -38,9 +38,10 @@ var Whisper = Whisper || {};
|
|||
},
|
||||
|
||||
validateNumber: function() {
|
||||
var input = this.$el.find('input.number');
|
||||
try {
|
||||
var regionCode = this.$el.find('li.active').attr('data-country-code').toUpperCase();
|
||||
var number = this.$el.find('input.number').val();
|
||||
var number = input.val();
|
||||
|
||||
var parsedNumber = libphonenumber.util.verifyNumber(number, regionCode);
|
||||
|
||||
|
@ -49,6 +50,8 @@ var Whisper = Whisper || {};
|
|||
return parsedNumber;
|
||||
} catch(e) {
|
||||
this.$el.find('.number-container').removeClass('valid');
|
||||
} finally {
|
||||
input.trigger('validation');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
</div>
|
||||
<script type="text/x-tmpl-mustache" id="phone-number">
|
||||
<div class="phone-input-form">
|
||||
<div class="number-container">
|
||||
<div id="number-container" class="number-container">
|
||||
<input type="tel" class="number" placeholder="Phone Number" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue