forked from mirrors/easyappointments
Define local variables for UMD libraries
This commit is contained in:
parent
a8996b6b99
commit
2999dcda87
1 changed files with 29 additions and 29 deletions
|
@ -34,6 +34,8 @@ App.Pages.Booking = (function () {
|
||||||
const $availableHours = $('#available-hours');
|
const $availableHours = $('#available-hours');
|
||||||
const $bookAppointmentSubmit = $('#book-appointment-submit');
|
const $bookAppointmentSubmit = $('#book-appointment-submit');
|
||||||
const $deletePersonalInformation = $('#delete-personal-information');
|
const $deletePersonalInformation = $('#delete-personal-information');
|
||||||
|
const tippy = window.tippy;
|
||||||
|
const moment = window.moment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the functionality of the page.
|
* Determines the functionality of the page.
|
||||||
|
@ -494,40 +496,38 @@ App.Pages.Booking = (function () {
|
||||||
$('#wizard-frame-3 .is-invalid').removeClass('is-invalid');
|
$('#wizard-frame-3 .is-invalid').removeClass('is-invalid');
|
||||||
$('#wizard-frame-3 label.text-danger').removeClass('text-danger');
|
$('#wizard-frame-3 label.text-danger').removeClass('text-danger');
|
||||||
|
|
||||||
try {
|
// Validate required fields.
|
||||||
// Validate required fields.
|
let missingRequiredField = false;
|
||||||
let missingRequiredField = false;
|
|
||||||
|
|
||||||
$('.required').each((index, requiredField) => {
|
$('.required').each((index, requiredField) => {
|
||||||
if (!$(requiredField).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(requiredField).addClass('is-invalid');
|
$(requiredField).addClass('is-invalid');
|
||||||
missingRequiredField = true;
|
missingRequiredField = true;
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (missingRequiredField) {
|
|
||||||
throw new Error(lang('fields_are_required'));
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Validate email address.
|
if (missingRequiredField) {
|
||||||
if ($email.val() && !App.Utils.Validation.email($email.val())) {
|
$('#form-message').text(lang('fields_are_required'));
|
||||||
$email.addClass('is-invalid');
|
|
||||||
throw new Error(lang('invalid_email'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate phone number.
|
|
||||||
const phoneNumber = $phoneNumber.val();
|
|
||||||
|
|
||||||
if (phoneNumber && !App.Utils.Validation.phone(phoneNumber)) {
|
|
||||||
$phoneNumber.addClass('is-invalid');
|
|
||||||
throw new Error(lang('invalid_phone'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} catch (error) {
|
|
||||||
$('#form-message').text(error.message);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate email address.
|
||||||
|
if ($email.val() && !App.Utils.Validation.email($email.val())) {
|
||||||
|
$email.addClass('is-invalid');
|
||||||
|
$('#form-message').text(lang('invalid_email'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate phone number.
|
||||||
|
const phoneNumber = $phoneNumber.val();
|
||||||
|
|
||||||
|
if (phoneNumber && !App.Utils.Validation.phone(phoneNumber)) {
|
||||||
|
$phoneNumber.addClass('is-invalid');
|
||||||
|
$('#form-message').text(lang('invalid_phone'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue