$(document).ready(function(){ $('#name3').empty(); // $(".toolbar toolbar-bottom").hide(); // $(".toolbar toolbar-bottom").css('display','none'); //Toolbar extra buttons var btnFinish = $('').text('Preview') .addClass('btn btn-info') .on('click', function(){ if(validateStep3() == false ){ isStepValid = false; var steps=2; $('#smartwizard').smartWizard('showMessage','Please correct the errors in step'+steps+ ' and click next.'); $('#smartwizard').smartWizard('setError',{stepnum:steps,iserror:true}); return false; }else{ $('#smartwizard').smartWizard('hideMessage'); $('#smartwizard').smartWizard('setError',{stepnum:steps,iserror:false}); } var html = ''; html += 'Name (as in SSLC/Equivalent)' + $("#txt_name").val() + ''; html += 'Date of Birth' + $("#txt_dob").val() + ''; html += 'Address' + $("#address").val() + ''; html += 'Religion' + $("#religion option:selected").text() + ''; html += 'Category' + $("#category option:selected").text() + ''; html += 'Caste' + $("#txt_caste").val() + ''; html += 'Is Eligible for Fee Exemption' + $("#txt_fee option:selected").text() + ''; html += 'Phone No.' + $("#txt_phone_number").val() + ''; html += 'SSLC ' + $("#txt_sslc_regno").val()+' , '+$("#sslc_month option:selected").text() +' '+ $("#txt_sslc_year").val() + ''; html += 'Institute Name' + $("#txt_institute").val() + ''; html += 'Centre name' + $("#centre option:selected").text() + ''; var val= $('input[name="subjectRadios"]:checked').val(); if(val=='regular'){ // // var val = $('#regular_subject').text(); html += 'Shorthand Centre' + $("#short_hand_centre option:selected").text() + ''; html += 'Regular Subject ' + $("#regular_subject option:selected").text() + ''; } if(val=='private'){ html += 'Part Subject ' + $("#private_subject option:selected").text() + ''; } var img_src = $("#preview").attr('src'); html += 'Photo'; $('#cand_preview_table tbody').html(html); $('#cand_preview_modal').modal(); // $.ajax({ // url: "controller/candController.php", // contentType: false, // success: function (results) // { // alert(results); // }, // error: function (xhr, status, error) { // errormsg("Error1:" + error); // } // }); }); // Step show event $("#smartwizard").on("showStep", function(e, anchorObject, stepNumber, stepDirection, stepPosition) { $("#prev-btn").removeClass('disabled'); // $("#next-btn").removeClass('disabled'); // $(".sw-btn-next").css("display", "block"); if(stepPosition === 'first') { $("#prev-btn").addClass('disabled'); $("#fnsh-btn").attr("disabled", "disabled"); // $(".toolbar toolbar-bottom").empty(); } else if(stepPosition === 'last') { // $(".toolbar toolbar-bottom").attr("disabled", "disabled"); // $(".btn sw-btn-prev").addClass('disabled'); $(".btn sw-btn-prev").addClass('disabled'); // $("#next-btn").attr("disabled", "disabled"); $("#fnsh-btn").attr("disabled", "disabled"); $(".toolbar-bottom").hide(); $(".tab-content").height("auto"); // $("toolbar toolbar-bottom").css("display", "none"); // $("#next-btn").addClass('disabled'); // $("#fnsh-btn").addClass('disabled'); // $("#fnsh-btn").attr("disabled", "disabled"); // $("#btn sw-btn-prev").attr("disabled", "disabled"); // $(".sw-btn-next").attr("disabled", "disabled"); // $('input[type="button"]').attr("disabled", "disabled"); // $('.toolbar toolbar-bottom').hide(); // $("#fnsh-btn").attr("disabled", "disabled"); // $(".toolbar toolbar-bottom").empty(); // $(".toolbar toolbar-bottom").attr("display", "none"); // $(".toolbar toolbar-bottom").css('display','none'); // $(".toolbar toolbar-bottom").empty(); // $("#prev-btn").attr("disabled", "disabled");; // $(".toolbar toolbar-bottom").remove(); // $(".btn sw-btn-prev").attr("disabled", "disabled"); // $(".btn sw-btn-prev").addClass('disabled'); } else { if(stepNumber=='1'){ // alert('step 2'); // $(".sw-btn-next").hide(); $(".sw-btn-next").attr("disabled", "disabled"); $("#fnsh-btn").removeAttr("disabled", "disabled"); // $(".tab-content").removeAttr("height"); // $(".tab-content").attr("height", "auto"); $(".tab-content").height("auto"); }else{ $("#prev-btn").removeClass('disabled'); // $(".sw-btn-next").show(); // $("#next-btn").addClass('disabled'); $("#fnsh-btn").attr("disabled", "disabled"); $(".sw-btn-next").removeAttr("disabled", "disabled"); } } }); // Smart Wizard $('#smartwizard').smartWizard({ selected: 0, theme: 'arrows', // default, arrows, dots, progress // darkMode: true, transition: { animation: 'none', // Effect on navigation, none/fade/slide-horizontal/slide-vertical/slide-swing }, toolbarSettings: { toolbarExtraButtons: [btnFinish] } }); // External Button Events // $("#reset-btn").on("click", function() { // // Reset wizard // $('#smartwizard').smartWizard("reset"); // return true; // }); $("#prev-btn").on("click", function() { // Navigate previous $('#smartwizard').smartWizard("prev"); return true; }); $("#next-btn").on("click", function() { // Navigate next $('#smartwizard').smartWizard("next"); return true; }); // Demo Button Events // $("#got_to_step").on("change", function() { // // Go to step // var step_index = $(this).val() - 1; // $('#smartwizard').smartWizard("goToStep", step_index); // return true; // }); $("#dark_mode").on("click", function() { // Change dark mode var options = { darkMode: $(this).prop("checked") }; $('#smartwizard').smartWizard("setOptions", options); return true; }); $("#is_justified").on("click", function() { // Change Justify var options = { justified: $(this).prop("checked") }; $('#smartwizard').smartWizard("setOptions", options); return true; }); $("#animation").on("change", function() { // Change theme var options = { transition: { animation: $(this).val() }, }; $('#smartwizard').smartWizard("setOptions", options); return true; }); $("#theme_selector").on("change", function() { // Change theme var options = { theme: $(this).val() }; $('#smartwizard').smartWizard("setOptions", options); return true; }); $("#private_subject").select2({ maximumSelectionLength: 4 }); // $("#eligibility_div").hide(); }); function saveCandidateDetails() { var task = $('#task_opt_hidden').val(); var fd = new FormData(); fd.append('photo', $('#photo')[0].files[0]); var other_data = $('#cand_reg').serializeArray(); $.each(other_data, function (key, input) { fd.append(input.name, input.value); }); fd.append('task', task); $("#reg_loading").show(); $("#reg_loading").html(''); $("#fnsh_btn").attr('disabled', true); $(".btn sw-btn-prev").attr('disabled', true); $.ajax({ url: "controller/candController.php", data: fd, // data: {fd:fd,tok: aTok}, contentType: false, processData: false, type: 'POST', success: function (results, textStatus, jqXHR) { $("#reg_loading").hide(); $("#smartwizard").smartWizard("next"); $('#cand_preview_modal').modal('hide'); // $("toolbar toolbar-bottom").css("display", "none"); $(".toolbar toolbar-bottom").empty(); $(".toolbar toolbar-bottom").html(''); $(".btn sw-btn-prev").attr("disabled", "disabled"); $(".btn sw-btn-prev").attr("disabled", "disabled"); $('#smartwizard').smartWizard("stepState", [0], "disable"); $('#smartwizard').smartWizard("stepState", [1], "disable"); $('#smartwizard').smartWizard("stepState", [2], "disable"); $(".tab-content").height("auto"); // trim(results); // if(trim(results)) // var iDiv = document.createElement('div'); // iDiv.id = 'block'; // iDiv.rel = "stylesheet"; // iDiv.className = 'blck'; // //document.getElementsByTagName('body')[0].appendChild(iDiv); // document.getElementById('name3').appendChild(iDiv); $('#name3').append('
You are Successfully completed 3 steps and Your '+results+' .Please make payment for final proceedings of your application.
'); // $("#save_btn").attr('disabled', true); // $("#edit_btn").attr('disabled', true); }, error: function (xhr, status, error) { $("#save_btn").removeAttr('disabled'); $("#edit_btn").removeAttr('disabled'); errormsg("Error1:" + error); } }); } function continueEditing() { $("#cand_preview_table tbody").html(''); $('#cand_preview_modal').modal('hide'); } function showinstruction() { swal('Upload photo having file size greater than 20 KB and not exceeding 30 KB. Supported formats are[jpeg,jpg] & dimension(Width X Height) 150px X 200px. '); } function showpdfinstruction() { swal('Upload pdf having file size greater than 1 KB and not exceeding 1 MB. Supported format is [pdf]'); } $('.text_upper').keyup(function () { this.value = this.value.toUpperCase(); }); // $("#smartwizard").on("leaveStep", function(e, anchorObject, stepNumber) { // alert(stepNumber); // $(".btn sw-btn-next").addClass('disabled'); // } ); $("#smartwizard").on("leaveStep1", function(e, anchorObject, stepNumber) { // var isStepValid,step; var isStepValid = true; var step=stepNumber; if(stepNumber == 0){ if(validateStep1() == false ){ isStepValid = false; $('#smartwizard').smartWizard('showMessage','Please correct the errors in step'+step+ ' and click next.'); $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:true}); return false; }else{ $('#smartwizard').smartWizard('hideMessage'); $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:false}); } } if(stepNumber == 1){ if(validateStep2() == false ){ isStepValid = false; $('#smartwizard').smartWizard('showMessage','Please correct the errors in step'+step+ ' and click next.'); $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:true}); return false; }else{ $('#smartwizard').smartWizard('hideMessage'); $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:false}); } } // if(stepNumber == 2){ // if(validateStep3() == false ){ // isStepValid = false; // $('#smartwizard').smartWizard('showMessage','Please correct the errors in step'+step+ ' and click next.'); // $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:true}); // return false; // }else{ // $('#smartwizard').smartWizard('hideMessage'); // $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:false}); // } // } }); // $(document).ready(function(){ // $('#smartwizard').smartWizard({onLeaveStep:leaveAStepCallback}); alert('h1332iii1i'); // $('#smartwizard').smartWizard({transitionEffect:'slideleft',onLeaveStep:leaveAStepCallback,onFinish:onFinishCallback,enableFinishButton:true}); // function leaveAStepCallback(obj){ // var step_num= obj.attr('rel'); // return validateSteps(step_num); // } // function onFinishCallback(){ // if(validateAllSteps()){ // $('form').submit(); // } // } // }); function validateSteps(step){ var isStepValid = true; // validate step 1 if(step == 1){ if(validateStep1() == false ){ isStepValid = false; $('#smartwizard').smartWizard('showMessage','Please correct the errors in step'+step+ ' and click next.'); $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:true}); }else{ $('#smartwizard').smartWizard('hideMessage'); $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:false}); } } // validate step3 // if(step == 3){ // if(validateStep3() == false ){ // isStepValid = false; // $('#smartwizard').smartWizard('showMessage','Please correct the errors in step'+step+ ' and click next.'); // $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:true}); // }else{ // $('#smartwizard').smartWizard('hideMessage'); // $('#smartwizard').smartWizard('setError',{stepnum:step,iserror:false}); // } // } return isStepValid; } function validateStep1(){ var isValid = true; // Validate Username var nm = $('#txt_name').val(); var dob=$("#txt_dob").val(); var addr=$("#address").val(); var rel=$("#religion").val(); var ct=$("#category").val(); var ph=$("#txt_phone_number").val(); if(!nm && nm.length <= 0){ isValid = false; $('#name').html('
Please fill name
').show(); $("#txt_name").focus(); }else if(!dob && dob.length <= 0){ isValid = false; $('#name').html('
Please fill Date of Birth
').show(); $("#txt_dob").focus(); }else if(!addr && addr.length <= 0){ isValid = false; $('#name').html('
Please fill Address
').show(); $("#address").focus(); }else if(!rel && rel.length <= 0){ isValid = false; $('#name').html('
Please fill Religion
').show(); $("#religion").focus(); }else if(!ct && ct.length <= 0){ isValid = false; $('#name').html('
Please fill Category
').show(); $("#category").focus(); } else if(!ph && ph.length <=0){ isValid = false; $('#name').html('
Please fill Mobile Number
').show(); $("#txt_phone_number").focus(); }else{ $('#name').html('').hide(); } return isValid; } function validateStep2(){ var isValid = true; // Validate data var sr = $('#txt_sslc_regno').val(); var sm=$("#sslc_month").val(); var sy=$("#txt_sslc_year").val(); var inst=$("#txt_institute").val(); var pto=$("#photo").val(); if(!sm && sm.length <= 0){ isValid = false; $('#name1').html('
Please fill SSLC Pass out Month
').show(); $("#sslc_month").focus(); }else if(!sy && sy.length <= 0){ isValid = false; $('#name1').html('
Please fill SSLC Pass out Year
').show(); $("#txt_sslc_year").focus(); }else if(!sr && sr.length <= 0){ isValid = false; $('#name1').html('
Please fill SSLC Register Number
').show(); $("#txt_sslc_regno").focus(); }else if(!inst && inst.length <= 0){ isValid = false; $('#name1').html('
Please fill Institute Name
').show(); $("#txt_institute").focus(); } else if(!pto && pto.length <= 0){ isValid = false; $('#name1').html('
Please Choose your Photo
').show(); $("#photo").focus(); } else{ // checkPhotoUpload(); isValid = true; $('#name1').empty(); if (window.File && window.FileReader && window.FileList && window.Blob) { var fsize = $('#photo')[0].files[0].size; var fileSize = fsize / 1024; var fileSize_rounded = +fileSize.toFixed(2); var ftype = $('#photo')[0].files[0].type; switch (ftype) { case 'image/jpeg': case 'image/jpg': break; default: isValid = false; $('#name1').html('
Unsupported image format for candidate photo.Image should be in jpeg or jpg formats only
').show(); $("#photo").val(''); $("#photo").focus(); $("#preview").removeAttr("src"); $("#preview").attr("src", "images/sample.png"); } // var fileExtension = ['jpeg', 'jpg']; // if ($.inArray(ftype, fileExtension) == -1) { // isValid = false; // $('#name1').html('
Unsupported image format for candidate photo.Image should be in jpeg or jpg formats only
').show(); // $("#photo").val(''); // $("#photo").focus(); // $("#preview").removeAttr("src"); // $("#preview").attr("src", "images/sample.png"); // } if ((fileSize < 20) || (fileSize > 30)) { isValid = false; $('#name1').html('
Uploaded candidate photo size is ' + fileSize_rounded + "KB" + ' . Upload candidate photo with file size not exceeding 30 KB and not less than 20 KB.
').show(); $("#photo").val(''); $("#photo").focus(); $("#preview").removeAttr("src"); $("#preview").attr("src", "images/sample.png"); } } else { isValid = false; $('#name1').html('
Please upgrade your browser, because your current browser lacks some new features we need!').show(); $("#photo").val(''); $("#photo").focus(); $("#preview").removeAttr("src"); $("#preview").attr("src", "images/sample.png"); } if(isValid=='true'){ $('#name1').html('').hide(); $(".btn sw-btn-next").addClass('disabled'); } } return isValid; } function validateStep3(){ var isValid = true; // Validate var sb; var cntr=$("#centre").val(); var shcntr=$("#short_hand_centre").val(); var val= $('input[name="subjectRadios"]:checked').val(); if(val=='regular'){ sb=$("#regular_subject").val(); $("#private_subject").val(''); }else if(val=='private'){ sb=$("#private_subject").val(); $("#regular_subject").val(''); } if(!cntr && cntr.length <= 0){ isValid = false; $('#name2').html('
Please fill Centre...!
').show(); $("#centre").focus(); }else if(!shcntr && shcntr.length <= 0 && val=='regular'){ isValid = false; $('#name2').html('
Please fill Shorthand Centre...!
').show(); $("#short_hand_centre").focus(); } else if(!sb || sb.length <= 0){ isValid = false; $('#name2').html('
Please fill Subjects...!
').show(); if(val=='regular'){ $("#regular_subject").focus(); }else if(val=='private'){ $("#private_subject").focus(); } } else{ $('#name2').html('').hide(); } return isValid; } $('.numeric_element').keypress(function (e) { var a = []; var k = e.which; for (i = 48; i < 58; i++) { a.push(i); } a.push(0); a.push(8); if (!($.inArray(k, a) >= 0)) { e.preventDefault(); } }); function checkPhotoUpload() { if (window.File && window.FileReader && window.FileList && window.Blob) { var fsize = $('#photo')[0].files[0].size; var fileSize = fsize / 1024; var fileSize_rounded = +fileSize.toFixed(2); var ftype = $('#photo')[0].files[0].type; switch (ftype) { case 'image/jpeg': case 'image/jpg': break; default: isValid = false; $("#photo").val(''); $("#photo").focus(); $("#preview").removeAttr("src"); $("#preview").attr("src", "images/sample.png"); $('#name1').html('
Unsupported image format for candidate photo.Image should be in jpeg or jpg formats only
').show(); return false; } if ((fileSize < 20) || (fileSize > 30)) { isValid = false; $("#photo").val(''); $("#photo").focus(); $("#preview").removeAttr("src"); $("#preview").attr("src", "images/sample.png"); $('#name1').html('
Uploaded candidate photo size is ' + fileSize_rounded + "KB" + ' . Upload candidate photo with file size not exceeding 30 KB and not less than 20 KB.
').show(); return false; } } else { isValid = false; $("#photo").val(''); $("#photo").focus(); $("#preview").removeAttr("src"); $("#preview").attr("src", "images/sample.png"); $('#name1').html('
Please upgrade your browser, because your current browser lacks some new features we need!').show(); return false; } isValid = true; return true; } $(window).keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); return false; } }); var wizardForm = $('#cand_reg'); wizardForm.on('keyup keypress', function(e) { var code = e.keyCode || e.which; if (code == 13) { e.preventDefault(); return false; } }); $('input[name=txt_phone_number]').keydown(function(e) { var code = e.keyCode || e.which; if (code === 9) { e.preventDefault(); } }); $('input[name=photo]').keydown(function(e) { var code = e.keyCode || e.which; if (code === 9) { e.preventDefault(); } }); // $('input[name=photo]').keydown(function(e) { // var code = e.keyCode || e.which; // if (code === 9) { // e.preventDefault(); // } // }); // $("#smartwizard").on("showStep", function(e, anchorObject, stepNumber, stepDirection) { // if($('button.sw-btn-next').hasClass('disabled')){ // $('.sw-btn-group-extra').show(); // show the button extra only in the last page // }else{ // $('.sw-btn-group-extra').hide(); // } // });