I've found an interesting jquery plugin to create a wizard it's name is Smart wizard 4. I want to be able to stop the user after the second step to wait until an invitation code was inserted and validated from my php script. Can anyone suggest me a way to achieve this? I've never used this plugin, so I can't figure out how to lock the wizard until this validation is done. Also I want to add a form that need to be completed after the second step, any suggestion will be appreciated.
UPDATE:
var okToPass = false;
$('#smartwizard').on('leaveStep', function(e, anchorObject, stepNumber, stepDirection){
window.alert(stepNumber);
if(stepDirection === 'forward'){
if(stepNumber === 0 && !okToPass){
var userEmail = $('#creator-email').val();
localStorage.setItem('email', userEmail);
$.ajax({
type: 'POST',
data: {user_email: userEmail},
url: 'event/new/user',
cache: false,
success: function(response){
okToPass = true;
console.log(response);
}
});
}
if(stepNumber === 1){
okToPass = false;
var userCode = $('#creator-code').val();
localStorage.setItem('code', userCode);
$.ajax({
type: 'POST',
data: {user_code: userCode},
url: 'event/new/verification',
cache: false,
success: function(response){
console.log(response);
if( response === true ){
okToPass = true;
}
else{
okToPass = false;
}
}
});
if( !okToPass ){
return false;
}
}
if(stepNumber === 2 && !okToPass){
var email = localStorage.getItem('email');
$('#registered-email').val(email);
$.ajax({
type: 'POST',
data: {user_code: userCode},
url: 'event/new/save',
cache: false,
success: function(response){
okToPass = true;
window.alert(response)
console.log(response);
}
});
}
}
});
I'm testing the code suggested and I have the problem that the user can't continue the wizard steps with my implementation of the code. The wizard will not go to the next step if the code is correct, but will stop the user if it will insert a wrong code. Any suggestion?