var okays = ''; $(document).ready( function(){ $('#prooffile').click( function(e){ e.preventDefault(); $('#mainbox').load('/cases/claimform.php', { 'case_id' : '342', 'case_title' : '197+Rumstick+Rd.%2C+Barrington%2C+RI', 'case_date' : '2016-04-29', 'case_deadline' : '2016-10-07' }, function(){ loadPageOne(okays); var formid = $('#form_id').val(); $('#file_upload').uploadify({ 'preventCaching' : 'false', 'fileSizeLimit' : '200MB', 'formData' : { 'token' : '83ebc8d7126a980ea5f433e10fddc9c5', 'session':'589fc6d8d3587856ade5a013c6e7d68b', 'formid' : formid }, 'multi' : true, 'swf' : '/cases/uploadify3/uploadify.swf', 'uploader' : '/cases/uploadify3/uploadify.php', 'onUploadComplete' : function(file) { $('#upload_file_list').append('
  • '+file.name+'
  • '); } }); }); return false; }); }); function loadPageOne(okays){ $('div#page_two,#page_three,#page_four,#page_one button.next,#page_two button.next').hide(); $('.date').datepicker({ changeMonth: true, changeYear: true }); $('#full_name').change( function(){ checkFieldData('full_name','pagetwo'); }); $('#send_address').blur( function(){ checkFieldData('send_address','pagetwo'); }); $('#phone_number').blur( function(){ checkFieldData('phone_number','pagetwo'); }); $('#email_address').blur( function(){ checkFieldData('email_address','pagetwo'); }); } function loadPageTwo(okays){ var thisval; if(okays.indexOf('full_name') > -1 && okays.indexOf('send_address') > -1 && okays.indexOf('phone_number') > -1 && okays.indexOf('email_address') > -1){ $('#page_one button.next').fadeIn(); $('#page_one button.ready').hide(); $('#page_two button.previous').click( function(e){ e.preventDefault(); $('#page_one').fadeIn(); $('#page_two').hide(); }); $('#page_one button.next').click( function(e){ e.preventDefault(); $('#page_one').hide(); $('#page_two').fadeIn(); $('#page_three button.previous').click( function(e){ e.preventDefault(); $('#page_two').fadeIn(); $('#page_three').hide(); }); $('.date').datepicker({ changeMonth: true, changeYear: true }); $('#claim_period').change( function(){ checkFieldData('claim_period','pagethree'); $('.alertfield.claim_period').hide(); }); $('#claim_amount').blur( function(){ thisval = $(this).val(); thisval = thisval.replace(',',''); $('#claim_amount').val(thisval); checkFieldData('claim_amount','pagethree'); checkNumber('claim_amount',thisval); }); $('#claim_amount_on_date_of_proof').blur( function(){ thisval = $(this).val(); thisval = thisval.replace(',',''); $('#claim_amount_on_date_of_proof').val(thisval); checkNumber('claim_amount_on_date_of_proof',thisval); }); $('#amount_secured').blur( function(){ thisval = $(this).val(); thisval = thisval.replace(',',''); $('#amount_secured').val(thisval); checkNumber('amount_secured',thisval); }); $('#amount_unsecured').blur( function(){ thisval = $(this).val(); thisval = thisval.replace(',',''); $('#amount_unsecured').val(thisval); checkNumber('amount_unsecured',thisval); }); $('#nature_of_alleged_debt').blur( function(){ checkFieldData('nature_of_alleged_debt','pagethree'); }); }); } } function loadPageThree(okays){ if(okays.indexOf('claim_amount') > -1 && okays.indexOf('nature_of_alleged_debt') > -1){ $('#page_two button.next').fadeIn(); $('#page_two button.ready').hide(); $('#page_two button.next').click( function(e){ e.preventDefault(); $('#page_two').hide(); $('#page_three').fadeIn(); loadPageFour(okays); $('#page_four button.previous').click( function(){ $('#page_three').fadeIn(); $('#page_two').hide(); }); }); } } function loadPageFour(okays){ $('#page_three button.next').fadeIn(); $('#page_three button.next').click( function(e){ e.preventDefault(); $('#page_three').hide(); $('#page_four').fadeIn(); var formdata = $('#claim_form').serialize(); $('.youranswers').load('/cases/review.php', {'formdata' : formdata }); $('#signature').load('/cases/signature.php', function(){ $('#digital_signature_check').change( function(){ var dsc = $('#digital_signature_check')[0].checked; if(dsc === true){ $('#submit_button').fadeIn(); var signed_name = $('#signed_name').val(); var signed_date = $('#signed_date').val(); $('#digital_signature_feedback').load('/cases/signature_verify.php', { 'signed_name': signed_name, 'signed_date' : signed_date },function(q){ if(q != 'incomplete'){ $('#digital_signature').val(q); $('#submit_button').click( function(s){ s.preventDefault(); var formdata = $('#claim_form').serialize(); $('.feedback').load('/cases/formprocess.php', formdata, function(f){ if(f.indexOf('complete') == -1){ $('#digital_signature_check').attr('checked',false); $('#final_submit_feedback').html('You are missing some required information. Please check the form and resubmit.'); } else { $('#mainbox').load('/cases/receipt.php', { 'formdata' : formdata }); scrollTo(0,0); } }); }); } else { $('#digital_signature_check').attr('checked',false); $('#final_submit_feedback').html('You must type your real name and submit the current address as mm/dd/yyyy.'); } }); } }); }); $('#page_four button.previous').click( function(e){ e.preventDefault(); $('#page_three').fadeIn(); $('#page_four').hide(); }); }); } function checkFieldData(field_name,nextpage){ $('.feedback').load('/cases/checkdata.php', { 'field' : field_name, 'value' : $('#'+field_name).val() }, function(r){ if(r == field_name){ $('.alertfield.'+field_name).fadeIn(); } else { okays = okays+field_name+'|'; //$('.feedback').append(' '+$('#'+field_name).val()); $('.alertfield.'+field_name).hide(); if(nextpage == 'pagetwo') loadPageTwo(okays); if(nextpage == 'pagethree') loadPageThree(okays); if(nextpage == 'pagefour') loadPageFour(okays); } }); } function checkNumber(field_name,value){ if(value){ $('#'+field_name+'_check').load('/cases/checknum.php', { 'value' : value }); } }