mam taki kod js
$(document).ready(function() {
$('#tabs').smartWizard({
keyNavigation : true,
labelNext : 'Następne', // label for Next button
labelPrevious : 'Poprzednie', // label for Previous button
labelFinish : 'Zakończ',
transitionEffect : 'slide',
onLeaveStep : leaveAStepCallback,
onFinish : function() {
$.ajax({
type : "POST",
url : base_url + "index.php/action/new_conference",
dataType : "json",
data : "title=" + $('#title').val() + "&pin=" + $('#pin').val() + "&start_time=" + $('#start_time').val() + "&date=" + $('#date').val() + "&end_time=" + $('#end_time').val() + "&users=" + $('#users').val(),
cache : false,
success : function(data) {
if (data.status) {
window.location.replace(base_url + "conference");
} else {
alert('Wystapił problem, skontaktuj się z administratorem');
}
}
});
}
});
function leaveAStepCallback(obj) {
var step_num = obj.attr('rel');
// get the current step number
return validateSteps(step_num);
// return false to stay on step and true to continue navigation
}
function validateSteps(step) {
var isStepValid = true;
// validate step 1
if (step == 1) {
if (validateStep1() == false) {
isStepValid = false;
$('#tabs').smartWizard('showMessage', 'Proszę podać tytuł konferencji');
$('#tabs').smartWizard('setError', {
stepnum : step,
iserror : true
});
} else {
$('#tabs').smartWizard('setError', {
stepnum : step,
iserror : false
});
$('.close').click();
}
}
if (step == 2) {
if (validateStep2() == false) {
isStepValid = false;
$('#tabs').smartWizard('showMessage', 'Data zakończenia nie może być wczesniejsza niż data rozpoczecia');
$('#tabs').smartWizard('setError', {
stepnum : step,
iserror : true
});
} else {
$('#tabs').smartWizard('setError', {
stepnum : step,
iserror : false
});
$('.close').click();
}
}
return isStepValid;
}
function validateStep1() {
var isValid = true;
// Validate Username
var title = $('#title').val();
if (!title && title.length <= 0) {
isValid = false;
} else {
isValid = true;
}
return isValid;
}
function validateStep2() {
var valid = true;
$.ajax({
type : "POST",
url : base_url + "index.php/action/check_date",
dataType : "json",
data : "end=" + $('#date').val() + ' ' + $('#end_time').val() + "&start=" + $('#date').val() + ' ' + $('#start_time').val(),
cache : false,
success : function(data) {
switch(data.status) {
case true:
valid = true;
return valid;
break;
default:
valid = false;
return valid;
break;
}
}
});
}
});
i nie mam pojęcia dlaczego pomimo tego, że funkcja zwraca false mogę przejść do następnego etapu co powinno być niemożliwe.