Used bootstrap form validation helpers.
This commit is contained in:
parent
3bc482adf4
commit
e505f2bd32
17 changed files with 113 additions and 118 deletions
|
@ -177,12 +177,12 @@
|
||||||
<div class="col-xs-12 col-sm-6">
|
<div class="col-xs-12 col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="start-datetime" class="control-label"><?= lang('start_date_time') ?></label>
|
<label for="start-datetime" class="control-label"><?= lang('start_date_time') ?></label>
|
||||||
<input id="start-datetime" class="form-control">
|
<input id="start-datetime" class="required form-control">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="end-datetime" class="control-label"><?= lang('end_date_time') ?></label>
|
<label for="end-datetime" class="control-label"><?= lang('end_date_time') ?></label>
|
||||||
<input id="end-datetime" class="form-control">
|
<input id="end-datetime" class="required form-control">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -92,42 +92,42 @@
|
||||||
<div id="form-message" class="alert" style="display:none;"></div>
|
<div id="form-message" class="alert" style="display:none;"></div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="first-name"><?= lang('first_name') ?> *</label>
|
<label class="control-label" for="first-name"><?= lang('first_name') ?> *</label>
|
||||||
<input id="first-name" class="form-control required">
|
<input id="first-name" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="last-name"><?= lang('last_name') ?> *</label>
|
<label class="control-label" for="last-name"><?= lang('last_name') ?> *</label>
|
||||||
<input id="last-name" class="form-control required">
|
<input id="last-name" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email"><?= lang('email') ?> *</label>
|
<label class="control-label" for="email"><?= lang('email') ?> *</label>
|
||||||
<input id="email" class="form-control required">
|
<input id="email" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="phone-number"><?= lang('phone_number') ?> *</label>
|
<label class="control-label" for="phone-number"><?= lang('phone_number') ?> *</label>
|
||||||
<input id="phone-number" class="form-control required">
|
<input id="phone-number" class="form-control required">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="address"><?= lang('address') ?></label>
|
<label class="control-label" for="address"><?= lang('address') ?></label>
|
||||||
<input id="address" class="form-control">
|
<input id="address" class="form-control">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="city"><?= lang('city') ?></label>
|
<label class="control-label" for="city"><?= lang('city') ?></label>
|
||||||
<input id="city" class="form-control">
|
<input id="city" class="form-control">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="zip-code"><?= lang('zip_code') ?></label>
|
<label class="control-label" for="zip-code"><?= lang('zip_code') ?></label>
|
||||||
<input id="zip-code" class="form-control">
|
<input id="zip-code" class="form-control">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="notes"><?= lang('notes') ?></label>
|
<label class="control-label" for="notes"><?= lang('notes') ?></label>
|
||||||
<textarea id="notes" rows="4" class="form-control"></textarea>
|
<textarea id="notes" rows="4" class="form-control"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
var $dialog = $('#manage-appointment');
|
var $dialog = $('#manage-appointment');
|
||||||
|
|
||||||
// Reset previous validation css formatting.
|
// Reset previous validation css formatting.
|
||||||
$dialog.find('.form-group').removeClass('has-error');
|
$dialog.find('.has-error').removeClass('has-error');
|
||||||
$dialog.find('.modal-message').addClass('hidden');
|
$dialog.find('.modal-message').addClass('hidden');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -467,7 +467,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
|
|
||||||
$dialog.find('.required').each(function() {
|
$dialog.find('.required').each(function() {
|
||||||
if ($(this).val() == '' || $(this).val() == null) {
|
if ($(this).val() == '' || $(this).val() == null) {
|
||||||
$(this).parents('.form-group').addClass('has-error');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequiredField = true;
|
missingRequiredField = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -478,7 +478,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
|
|
||||||
// Check email address.
|
// Check email address.
|
||||||
if (!GeneralFunctions.validateEmail($dialog.find('#email').val())) {
|
if (!GeneralFunctions.validateEmail($dialog.find('#email').val())) {
|
||||||
$dialog.find('#email').parents('.form-group').eq(1).addClass('has-error');
|
$dialog.find('#email').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,8 +486,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
var start = $('#start-datetime').datetimepicker('getDate');
|
var start = $('#start-datetime').datetimepicker('getDate');
|
||||||
var end = $('#end-datetime').datetimepicker('getDate');
|
var end = $('#end-datetime').datetimepicker('getDate');
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
$dialog.find('#start-datetime').parents('.form-group').addClass('has-error');
|
$dialog.find('#start-datetime, #end-datetime').closest('.form-group').addClass('has-error');
|
||||||
$dialog.find('#end-datetime').parents('.form-group').addClass('has-error');
|
|
||||||
throw EALang.start_date_before_end_error;
|
throw EALang.start_date_before_end_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili
|
||||||
*/
|
*/
|
||||||
$('#manage-unavailable #save-unavailable').click(function() {
|
$('#manage-unavailable #save-unavailable').click(function() {
|
||||||
var $dialog = $('#manage-unavailable');
|
var $dialog = $('#manage-unavailable');
|
||||||
|
$dialog.find('.has-error').removeClass('has-error');
|
||||||
var start = $dialog.find('#unavailable-start').datetimepicker('getDate');
|
var start = $dialog.find('#unavailable-start').datetimepicker('getDate');
|
||||||
var end = Date.parse($dialog.find('#unavailable-end').datetimepicker('getDate'));
|
var end = Date.parse($dialog.find('#unavailable-end').datetimepicker('getDate'));
|
||||||
|
|
||||||
|
@ -39,6 +40,8 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili
|
||||||
.text(EALang.start_date_before_end_error)
|
.text(EALang.start_date_before_end_error)
|
||||||
.addClass('alert-danger')
|
.addClass('alert-danger')
|
||||||
.removeClass('hidden');
|
.removeClass('hidden');
|
||||||
|
|
||||||
|
$dialog.find('#unavailable-start, #unavailable-end').closest('.form-group').addClass('has-error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,8 +139,9 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('.calendar-view').length === 0) {
|
if ($('.calendar-view').length === 0) {
|
||||||
$dialog.find('#unavailable-provider').val($('#select-filter-item').val())
|
$dialog.find('#unavailable-provider')
|
||||||
.parents('.form-group')
|
.val($('#select-filter-item').val())
|
||||||
|
.closest('.form-group')
|
||||||
.hide();
|
.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
category.id = $('#category-id').val();
|
category.id = $('#category-id').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance.validate(category)) {
|
if (!instance.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,17 +263,17 @@
|
||||||
/**
|
/**
|
||||||
* Validate category data before save (insert or update).
|
* Validate category data before save (insert or update).
|
||||||
*
|
*
|
||||||
* @param {Object} category Contains the category data.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
CategoriesHelper.prototype.validate = function(category) {
|
CategoriesHelper.prototype.validate = function() {
|
||||||
$('#categories .record-details').find('input, textarea').css('border', '');
|
$('#categories .has-error').removeClass('has-error');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
|
|
||||||
$('#categories .required').each(function() {
|
$('#categories .required').each(function() {
|
||||||
if ($(this).val() === '' || $(this).val() === undefined) {
|
if ($(this).val() === '' || $(this).val() === undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -283,7 +283,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(exc) {
|
} catch(message) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,7 +158,9 @@
|
||||||
customer.id = $('#customer-id').val();
|
customer.id = $('#customer-id').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance.validate(customer)) return;
|
if (!instance.validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
instance.save(customer);
|
instance.save(customer);
|
||||||
});
|
});
|
||||||
|
@ -238,12 +240,12 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate customer data before save (insert or update).
|
* Validate customer data before save (insert or update).
|
||||||
*
|
|
||||||
* @param {Object} customer Contains the customer data.
|
|
||||||
*/
|
*/
|
||||||
CustomersHelper.prototype.validate = function(customer) {
|
CustomersHelper.prototype.validate = function() {
|
||||||
$('#form-message').hide();
|
$('#form-message')
|
||||||
$('.required').css('border', '');
|
.removeClass('alert-danger')
|
||||||
|
.hide();
|
||||||
|
$('.has-error').removeClass('has-error');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
|
@ -251,7 +253,7 @@
|
||||||
|
|
||||||
$('.required').each(function() {
|
$('.required').each(function() {
|
||||||
if ($(this).val() == '') {
|
if ($(this).val() == '') {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -262,14 +264,16 @@
|
||||||
|
|
||||||
// Validate email address.
|
// Validate email address.
|
||||||
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
||||||
$('#email').css('border', '2px solid red');
|
$('#email').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch(message) {
|
||||||
} catch(exc) {
|
$('#form-message')
|
||||||
$('#form-message').text(exc).show();
|
.addClass('alert-danger')
|
||||||
|
.text(message)
|
||||||
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -287,7 +291,7 @@
|
||||||
$('#add-edit-delete-group').show();
|
$('#add-edit-delete-group').show();
|
||||||
$('#save-cancel-group').hide();
|
$('#save-cancel-group').hide();
|
||||||
|
|
||||||
$('.record-details .required').css('border', '');
|
$('.record-details .has-error').removeClass('has-error');
|
||||||
$('.record-details #form-message').hide();
|
$('.record-details #form-message').hide();
|
||||||
|
|
||||||
$('#filter-customers button').prop('disabled', false);
|
$('#filter-customers button').prop('disabled', false);
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
service.id = $('#service-id').val();
|
service.id = $('#service-id').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance.validate(service)) {
|
if (!instance.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,12 +235,10 @@
|
||||||
/**
|
/**
|
||||||
* Validates a service record.
|
* Validates a service record.
|
||||||
*
|
*
|
||||||
* @param {Object} service Contains the service data.
|
|
||||||
*
|
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
ServicesHelper.prototype.validate = function(service) {
|
ServicesHelper.prototype.validate = function() {
|
||||||
$('#services .required').css('border', '');
|
$('#services .has-error').removeClass('has-error');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// validate required fields.
|
// validate required fields.
|
||||||
|
@ -248,7 +246,7 @@
|
||||||
|
|
||||||
$('#services .required').each(function() {
|
$('#services .required').each(function() {
|
||||||
if ($(this).val() == '' || $(this).val() == undefined) {
|
if ($(this).val() == '' || $(this).val() == undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -199,11 +199,11 @@ window.BackendSettings = window.BackendSettings || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == false) {
|
if (response == false) {
|
||||||
$input.css('border', '2px solid red');
|
$input.closest('.form-group').addClass('has-error');
|
||||||
Backend.displayNotification(EALang.username_already_exists);
|
Backend.displayNotification(EALang.username_already_exists);
|
||||||
$input.attr('already-exists', 'true');
|
$input.attr('already-exists', 'true');
|
||||||
} else {
|
} else {
|
||||||
$input.css('border', '');
|
$input.closest('.form-group').removeClass('has-error');
|
||||||
$input.attr('already-exists', 'false');
|
$input.attr('already-exists', 'false');
|
||||||
}
|
}
|
||||||
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
||||||
|
|
|
@ -103,14 +103,14 @@
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
SystemSettings.prototype.validate = function() {
|
SystemSettings.prototype.validate = function() {
|
||||||
$('#general .required').css('border', '');
|
$('#general .has-error').removeClass('has-error');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#general .required').each(function() {
|
$('#general .required').each(function() {
|
||||||
if ($(this).val() == '' || $(this).val() == undefined) {
|
if ($(this).val() == '' || $(this).val() == undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -121,13 +121,13 @@
|
||||||
|
|
||||||
// Validate company email address.
|
// Validate company email address.
|
||||||
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
|
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
|
||||||
$('#company-email').css('border', '2px solid red');
|
$('#company-email').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(exc) {
|
} catch(message) {
|
||||||
Backend.displayNotification(exc);
|
Backend.displayNotification(message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,15 +91,14 @@
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
UserSettings.prototype.validate = function() {
|
UserSettings.prototype.validate = function() {
|
||||||
$('#user .required').css('border', '');
|
$('#user .has-error').removeClass('has-error');
|
||||||
$('#user').find('#password, #retype-password').css('border', '');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#user .required').each(function() {
|
$('#user .required').each(function() {
|
||||||
if ($(this).val() === '' || $(this).val() === undefined) {
|
if ($(this).val() === '' || $(this).val() === undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -110,18 +109,18 @@
|
||||||
|
|
||||||
// Validate passwords (if provided).
|
// Validate passwords (if provided).
|
||||||
if ($('#password').val() != $('#retype-password').val()) {
|
if ($('#password').val() != $('#retype-password').val()) {
|
||||||
$('#password, #retype-password').css('border', '2px solid red');
|
$('#password, #retype-password').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.passwords_mismatch;
|
throw EALang.passwords_mismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate user email.
|
// Validate user email.
|
||||||
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
||||||
$('#email').css('border', '2px solid red');
|
$('#email').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#username').attr('already-exists') === 'true') {
|
if ($('#username').attr('already-exists') === 'true') {
|
||||||
$('#username').css('border', '2px solid red');
|
$('#username').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.username_already_exists;
|
throw EALang.username_already_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,12 +203,12 @@ window.BackendUsers = window.BackendUsers || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response == false) {
|
if (response == false) {
|
||||||
$input.css('border', '2px solid red');
|
$input.closest('.form-group').addClass('has-error');
|
||||||
$input.attr('already-exists', 'true');
|
$input.attr('already-exists', 'true');
|
||||||
$input.parents().eq(3).find('.form-message').text(EALang.username_already_exists);
|
$input.parents().eq(3).find('.form-message').text(EALang.username_already_exists);
|
||||||
$input.parents().eq(3).find('.form-message').show();
|
$input.parents().eq(3).find('.form-message').show();
|
||||||
} else {
|
} else {
|
||||||
$input.css('border', '');
|
$input.closest('.form-group').removeClass('has-error');
|
||||||
$input.attr('already-exists', 'false');
|
$input.attr('already-exists', 'false');
|
||||||
if ($input.parents().eq(3).find('.form-message').text() == EALang.username_already_exists) {
|
if ($input.parents().eq(3).find('.form-message').text() == EALang.username_already_exists) {
|
||||||
$input.parents().eq(3).find('.form-message').hide();
|
$input.parents().eq(3).find('.form-message').hide();
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
admin.id = $('#admin-id').val();
|
admin.id = $('#admin-id').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.validate(admin)) {
|
if (!this.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,13 +235,10 @@
|
||||||
/**
|
/**
|
||||||
* Validates an admin record.
|
* Validates an admin record.
|
||||||
*
|
*
|
||||||
* @param {Object} admin Contains the admin data to be validated.
|
|
||||||
*
|
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
AdminsHelper.prototype.validate = function(admin) {
|
AdminsHelper.prototype.validate = function() {
|
||||||
$('#admins .required').css('border', '');
|
$('#admins .has-error').removeClass('has-error');
|
||||||
$('#admin-password, #admin-password-confirm').css('border', '');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
|
@ -249,7 +246,7 @@
|
||||||
|
|
||||||
$('#admins .required').each(function() {
|
$('#admins .required').each(function() {
|
||||||
if ($(this).val() == '' || $(this).val() == undefined) {
|
if ($(this).val() == '' || $(this).val() == undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -260,32 +257,34 @@
|
||||||
|
|
||||||
// Validate passwords.
|
// Validate passwords.
|
||||||
if ($('#admin-password').val() != $('#admin-password-confirm').val()) {
|
if ($('#admin-password').val() != $('#admin-password-confirm').val()) {
|
||||||
$('#admin-password, #admin-password-confirm').css('border', '2px solid red');
|
$('#admin-password, #admin-password-confirm').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.passwords_mismatch;
|
throw EALang.passwords_mismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#admin-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
|
if ($('#admin-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
|
||||||
&& $('#admin-password').val() != '') {
|
&& $('#admin-password').val() != '') {
|
||||||
$('#admin-password, #admin-password-confirm').css('border', '2px solid red');
|
$('#admin-password, #admin-password-confirm').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH);
|
throw EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate user email.
|
// Validate user email.
|
||||||
if (!GeneralFunctions.validateEmail($('#admin-email').val())) {
|
if (!GeneralFunctions.validateEmail($('#admin-email').val())) {
|
||||||
$('#admin-email').css('border', '2px solid red');
|
$('#admin-email').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if username exists
|
// Check if username exists
|
||||||
if ($('#admin-username').attr('already-exists') == 'true') {
|
if ($('#admin-username').attr('already-exists') == 'true') {
|
||||||
$('#admin-username').css('border', '2px solid red');
|
$('#admin-username').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.username_already_exists;
|
throw EALang.username_already_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(exc) {
|
} catch(message) {
|
||||||
$('#admins .form-message').text(exc);
|
$('#admins .form-message')
|
||||||
$('#admins .form-message').show();
|
.addClass('alert-danger')
|
||||||
|
.text(message)
|
||||||
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -300,8 +299,6 @@
|
||||||
$('#admins .record-details').find('select').prop('disabled', true);
|
$('#admins .record-details').find('select').prop('disabled', true);
|
||||||
$('#admins .form-message').hide();
|
$('#admins .form-message').hide();
|
||||||
$('#admin-notifications').prop('disabled', true);
|
$('#admin-notifications').prop('disabled', true);
|
||||||
$('#admins .required').css('border', '');
|
|
||||||
$('#admin-password, #admin-password-confirm').css('border', '');
|
|
||||||
$('#admins .record-details').find('input, textarea').val('');
|
$('#admins .record-details').find('input, textarea').val('');
|
||||||
$('#admin-notifications').removeClass('active');
|
$('#admin-notifications').removeClass('active');
|
||||||
$('#edit-admin, #delete-admin').prop('disabled', true);
|
$('#edit-admin, #delete-admin').prop('disabled', true);
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
provider.id = $('#provider-id').val();
|
provider.id = $('#provider-id').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.validate(provider)) {
|
if (!this.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,20 +288,17 @@
|
||||||
/**
|
/**
|
||||||
* Validates a provider record.
|
* Validates a provider record.
|
||||||
*
|
*
|
||||||
* @param {Object} provider Contains the admin data to be validated.
|
|
||||||
*
|
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
ProvidersHelper.prototype.validate = function(provider) {
|
ProvidersHelper.prototype.validate = function() {
|
||||||
$('#providers .required').css('border', '');
|
$('#providers .has-error').removeClass('has-error');
|
||||||
$('#provider-password, #provider-password-confirm').css('border', '');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#providers .required').each(function() {
|
$('#providers .required').each(function() {
|
||||||
if ($(this).val() == '' || $(this).val() == undefined) {
|
if ($(this).val() == '' || $(this).val() == undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -311,32 +308,34 @@
|
||||||
|
|
||||||
// Validate passwords.
|
// Validate passwords.
|
||||||
if ($('#provider-password').val() != $('#provider-password-confirm').val()) {
|
if ($('#provider-password').val() != $('#provider-password-confirm').val()) {
|
||||||
$('#provider-password, #provider-password-confirm').css('border', '2px solid red');
|
$('#provider-password, #provider-password-confirm').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.passwords_mismatch;
|
throw EALang.passwords_mismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#provider-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
|
if ($('#provider-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
|
||||||
&& $('#provider-password').val() != '') {
|
&& $('#provider-password').val() != '') {
|
||||||
$('#provider-password, #provider-password-confirm').css('border', '2px solid red');
|
$('#provider-password, #provider-password-confirm').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH);
|
throw EALang.password_length_notice.replace('$number', BackendUsers.MIN_PASSWORD_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate user email.
|
// Validate user email.
|
||||||
if (!GeneralFunctions.validateEmail($('#provider-email').val())) {
|
if (!GeneralFunctions.validateEmail($('#provider-email').val())) {
|
||||||
$('#provider-email').css('border', '2px solid red');
|
$('#provider-email').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if username exists
|
// Check if username exists
|
||||||
if ($('#provider-username').attr('already-exists') == 'true') {
|
if ($('#provider-username').attr('already-exists') == 'true') {
|
||||||
$('#provider-username').css('border', '2px solid red');
|
$('#provider-username').closest('.form-group').addClass('has-error');
|
||||||
throw EALang.username_already_exists;
|
throw EALang.username_already_exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(exc) {
|
} catch(message) {
|
||||||
$('#providers .form-message').text(exc);
|
$('#providers .form-message')
|
||||||
$('#providers .form-message').show();
|
.addClass('alert-danger')
|
||||||
|
.text(message)
|
||||||
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -358,8 +357,6 @@
|
||||||
$('#provider-notifications').removeClass('active');
|
$('#provider-notifications').removeClass('active');
|
||||||
$('#provider-notifications').prop('disabled', true);
|
$('#provider-notifications').prop('disabled', true);
|
||||||
$('#provider-services input:checkbox').prop('disabled', true);
|
$('#provider-services input:checkbox').prop('disabled', true);
|
||||||
$('#providers .required').css('border', '');
|
|
||||||
$('#provider-password, #provider-password-confirm').css('border', '');
|
|
||||||
$('#providers .add-break, #reset-working-plan').prop('disabled', true);
|
$('#providers .add-break, #reset-working-plan').prop('disabled', true);
|
||||||
BackendUsers.wp.timepickers(true);
|
BackendUsers.wp.timepickers(true);
|
||||||
$('#providers .working-plan input:text').timepicker('destroy');
|
$('#providers .working-plan input:text').timepicker('destroy');
|
||||||
|
|
|
@ -177,7 +177,7 @@
|
||||||
secretary.id = $('#secretary-id').val();
|
secretary.id = $('#secretary-id').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.validate(secretary)) {
|
if (!this.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,20 +247,18 @@
|
||||||
/**
|
/**
|
||||||
* Validates a secretary record.
|
* Validates a secretary record.
|
||||||
*
|
*
|
||||||
* @param {Object} secretary Contains the admin data to be validated.
|
|
||||||
*
|
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
SecretariesHelper.prototype.validate = function(secretary) {
|
SecretariesHelper.prototype.validate = function() {
|
||||||
$('#secretaries .required').css('border', '');
|
$('#secretaries .has-error').removeClass('has-error');
|
||||||
$('#secretary-password, #secretary-password-confirm').css('border', '');
|
$('#secretaries .form-message').removeClass('alert-danger');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#secretaries .required').each(function() {
|
$('#secretaries .required').each(function() {
|
||||||
if ($(this).val() == '' || $(this).val() == undefined) {
|
if ($(this).val() == '' || $(this).val() == undefined) {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -270,33 +268,35 @@
|
||||||
|
|
||||||
// Validate passwords.
|
// Validate passwords.
|
||||||
if ($('#secretary-password').val() != $('#secretary-password-confirm').val()) {
|
if ($('#secretary-password').val() != $('#secretary-password-confirm').val()) {
|
||||||
$('#secretary-password, #secretary-password-confirm').css('border', '2px solid red');
|
$('#secretary-password, #secretary-password-confirm').closest('.form-group').addClass('has-error');
|
||||||
throw 'Passwords mismatch!';
|
throw 'Passwords mismatch!';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#secretary-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
|
if ($('#secretary-password').val().length < BackendUsers.MIN_PASSWORD_LENGTH
|
||||||
&& $('#secretary-password').val() != '') {
|
&& $('#secretary-password').val() != '') {
|
||||||
$('#secretary-password, #secretary-password-confirm').css('border', '2px solid red');
|
$('#secretary-password, #secretary-password-confirm').closest('.form-group').addClass('has-error');
|
||||||
throw 'Password must be at least ' + BackendUsers.MIN_PASSWORD_LENGTH
|
throw 'Password must be at least ' + BackendUsers.MIN_PASSWORD_LENGTH
|
||||||
+ ' characters long.';
|
+ ' characters long.';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate user email.
|
// Validate user email.
|
||||||
if (!GeneralFunctions.validateEmail($('#secretary-email').val())) {
|
if (!GeneralFunctions.validateEmail($('#secretary-email').val())) {
|
||||||
$('#secretary-email').css('border', '2px solid red');
|
$('#secretary-email').closest('.form-group').addClass('has-error');
|
||||||
throw 'Invalid email address!';
|
throw 'Invalid email address!';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if username exists
|
// Check if username exists
|
||||||
if ($('#secretary-username').attr('already-exists') == 'true') {
|
if ($('#secretary-username').attr('already-exists') == 'true') {
|
||||||
$('#secretary-username').css('border', '2px solid red');
|
$('#secretary-username').closest('.form-group').addClass('has-error');
|
||||||
throw 'Username already exists.';
|
throw 'Username already exists.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch(exc) {
|
} catch(message) {
|
||||||
$('#secretaries .form-message').text(exc);
|
$('#secretaries .form-message')
|
||||||
$('#secretaries .form-message').show();
|
.addClass('alert-danger')
|
||||||
|
.text(message)
|
||||||
|
.show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -316,8 +316,7 @@
|
||||||
$('#secretary-notifications').prop('disabled', true);
|
$('#secretary-notifications').prop('disabled', true);
|
||||||
$('#secretary-providers input:checkbox').prop('checked', false);
|
$('#secretary-providers input:checkbox').prop('checked', false);
|
||||||
$('#secretary-providers input:checkbox').prop('disabled', true);
|
$('#secretary-providers input:checkbox').prop('disabled', true);
|
||||||
$('#secretaries .required').css('border', '');
|
$('#secretaries .has-error').removeClass('has-error');
|
||||||
$('#secretary-password, #secretary-password-confirm').css('border', '');
|
|
||||||
|
|
||||||
$('#filter-secretaries .selected').removeClass('selected');
|
$('#filter-secretaries .selected').removeClass('selected');
|
||||||
$('#filter-secretaries button').prop('disabled', false);
|
$('#filter-secretaries button').prop('disabled', false);
|
||||||
|
|
|
@ -345,7 +345,7 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
* @return {Boolean} Returns the validation result.
|
* @return {Boolean} Returns the validation result.
|
||||||
*/
|
*/
|
||||||
function _validateCustomerForm() {
|
function _validateCustomerForm() {
|
||||||
$('#wizard-frame-3 input').css('border', '');
|
$('#wizard-frame-3 input').closest('.form-group').removeClass('has-error');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
|
@ -353,7 +353,6 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
$('.required').each(function() {
|
$('.required').each(function() {
|
||||||
if ($(this).val() == '') {
|
if ($(this).val() == '') {
|
||||||
$(this).parents('.form-group').addClass('has-error');
|
$(this).parents('.form-group').addClass('has-error');
|
||||||
// $(this).css('border', '2px solid red');
|
|
||||||
missingRequiredField = true;
|
missingRequiredField = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -364,7 +363,6 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
// Validate email address.
|
// Validate email address.
|
||||||
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
||||||
$('#email').parents('.form-group').addClass('has-error');
|
$('#email').parents('.form-group').addClass('has-error');
|
||||||
// $('#email').css('border', '2px solid red');
|
|
||||||
throw EALang.invalid_email;
|
throw EALang.invalid_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,9 +112,9 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
||||||
var $captchaText = $('.captcha-text');
|
var $captchaText = $('.captcha-text');
|
||||||
|
|
||||||
if ($captchaText.length > 0) {
|
if ($captchaText.length > 0) {
|
||||||
$captchaText.css('border', '');
|
$captchaText.closest('.form-group').removeClass('has-error');
|
||||||
if ($captchaText.val() === '') {
|
if ($captchaText.val() === '') {
|
||||||
$captchaText.css('border', '1px solid #dc3b40');
|
$captchaText.closest('.form-group').addClass('has-error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
||||||
|
|
||||||
$('.captcha-title small').trigger('click');
|
$('.captcha-title small').trigger('click');
|
||||||
|
|
||||||
$captchaText.css('border', '1px solid #dc3b40');
|
$captchaText.closest('.form-group').addClass('has-error');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,13 +83,13 @@ $(document).ready(function() {
|
||||||
function validate() {
|
function validate() {
|
||||||
try {
|
try {
|
||||||
$('.alert').hide();
|
$('.alert').hide();
|
||||||
$('input').css('border', '');
|
$('input').closest('.form-group').removeClass('has-error');
|
||||||
|
|
||||||
// Check for empty fields.
|
// Check for empty fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('input').each(function() {
|
$('input').each(function() {
|
||||||
if ($(this).val() == '') {
|
if ($(this).val() == '') {
|
||||||
$(this).css('border', '2px solid red');
|
$(this).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -100,25 +100,25 @@ $(document).ready(function() {
|
||||||
|
|
||||||
// Validate Passwords
|
// Validate Passwords
|
||||||
if ($('#password').val() != $('#retype-password').val()) {
|
if ($('#password').val() != $('#retype-password').val()) {
|
||||||
$('#password').css('border', '2px solid red');
|
$('#password').closest('.form-group').addClass('has-error');
|
||||||
$('#retype-password').css('border', '2px solid red');
|
$('#retype-password').closest('.form-group').addClass('has-error');
|
||||||
throw 'Passwords do not match!';
|
throw 'Passwords do not match!';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#password').val().length < MIN_PASSWORD_LENGTH) {
|
if ($('#password').val().length < MIN_PASSWORD_LENGTH) {
|
||||||
$('#password').css('border', '2px solid red');
|
$('#password').closest('.form-group').addClass('has-error');
|
||||||
$('#retype-password').css('border', '2px solid red');
|
$('#retype-password').closest('.form-group').addClass('has-error');
|
||||||
throw 'The password must be at least ' + MIN_PASSWORD_LENGTH + ' characters long.';
|
throw 'The password must be at least ' + MIN_PASSWORD_LENGTH + ' characters long.';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate Email
|
// Validate Email
|
||||||
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
if (!GeneralFunctions.validateEmail($('#email').val())) {
|
||||||
$('#email').css('border', '2px solid red');
|
$('#email').closest('.form-group').addClass('has-error');
|
||||||
throw 'The email address is invalid!';
|
throw 'The email address is invalid!';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
|
if (!GeneralFunctions.validateEmail($('#company-email').val())) {
|
||||||
$('#company-email').css('border', '2px solid red');
|
$('#company-email').closest('.form-group').addClass('has-error');
|
||||||
throw 'The email address is invalid!';
|
throw 'The email address is invalid!';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue