forked from mirrors/easyappointments
Add soft phone number validation (#820).
This commit is contained in:
parent
08f09d66a9
commit
e659bd6e08
33 changed files with 109 additions and 2 deletions
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -337,4 +337,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -338,4 +338,5 @@ $lang['display'] = 'Display';
|
|||
$lang['require'] = 'Require';
|
||||
$lang['color'] = 'Color';
|
||||
$lang['matomo_analytics_url_hint'] = 'Add the URL to your own Matomo installation to enable Matomo tracking on the booking pages.';
|
||||
$lang['invalid_phone'] = 'Invalid phone number.';
|
||||
// End
|
||||
|
|
|
@ -292,6 +292,22 @@ App.Pages.Admins = (function () {
|
|||
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'));
|
||||
}
|
||||
|
||||
// Validate mobile number.
|
||||
const mobileNumber = $mobileNumber.val();
|
||||
|
||||
if (mobileNumber && !App.Utils.Validation.phone(mobileNumber)) {
|
||||
$mobileNumber.addClass('is-invalid');
|
||||
throw new Error(lang('invalid_phone'));
|
||||
}
|
||||
|
||||
// Check if username exists
|
||||
if ($username.attr('already-exists') === 'true') {
|
||||
$username.addClass('is-invalid');
|
||||
|
|
|
@ -552,6 +552,14 @@ App.Pages.Booking = (function () {
|
|||
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);
|
||||
|
|
|
@ -213,11 +213,21 @@ App.Pages.Customers = (function () {
|
|||
}
|
||||
|
||||
// Validate email address.
|
||||
if (!App.Utils.Validation.email($email.val())) {
|
||||
const email = $email.val();
|
||||
|
||||
if (email && !App.Utils.Validation.email(email)) {
|
||||
$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) {
|
||||
$formMessage.addClass('alert-danger').text(error.message).show();
|
||||
|
|
|
@ -300,6 +300,22 @@ App.Pages.Providers = (function () {
|
|||
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'));
|
||||
}
|
||||
|
||||
// Validate mobile number.
|
||||
const mobileNumber = $mobileNumber.val();
|
||||
|
||||
if (mobileNumber && !App.Utils.Validation.phone(mobileNumber)) {
|
||||
$mobileNumber.addClass('is-invalid');
|
||||
throw new Error(lang('invalid_phone'));
|
||||
}
|
||||
|
||||
// Check if username exists
|
||||
if ($username.attr('already-exists') === 'true') {
|
||||
$username.addClass('is-invalid');
|
||||
|
|
|
@ -305,6 +305,22 @@ App.Pages.Secretaries = (function () {
|
|||
throw new Error('Invalid email address!');
|
||||
}
|
||||
|
||||
// Validate phone number.
|
||||
const phoneNumber = $phoneNumber.val();
|
||||
|
||||
if (phoneNumber && !App.Utils.Validation.phone(phoneNumber)) {
|
||||
$phoneNumber.addClass('is-invalid');
|
||||
throw new Error(lang('invalid_phone'));
|
||||
}
|
||||
|
||||
// Validate mobile number.
|
||||
const mobileNumber = $mobileNumber.val();
|
||||
|
||||
if (mobileNumber && !App.Utils.Validation.phone(mobileNumber)) {
|
||||
$mobileNumber.addClass('is-invalid');
|
||||
throw new Error(lang('invalid_phone'));
|
||||
}
|
||||
|
||||
// Check if username exists
|
||||
if ($username.attr('already-exists') === 'true') {
|
||||
$username.addClass('is-invalid');
|
||||
|
|
|
@ -29,7 +29,21 @@ window.App.Utils.Validation = (function () {
|
|||
return re.test(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the provided phone.
|
||||
*
|
||||
* @param {String} value
|
||||
*
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function phone(value) {
|
||||
const re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im;
|
||||
|
||||
return re.test(value);
|
||||
}
|
||||
|
||||
return {
|
||||
email
|
||||
email,
|
||||
phone
|
||||
};
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue