2016-04-26 5 views
0

Ich möchte die Upload-Schaltfläche validieren, bevor Sie die saveBank()-Schaltfläche abschicken. Vor dem Senden des Formulars muss der Datei-Upload-Button für den Klick nach der Vorschau des Bildes validiert werden.Ich möchte die Upload-Schaltfläche validieren, bevor ich die letzte sbitmit-Taste saveBank() senden kann

<form id="panCopyUp" action="" method="post" enctype="multipart/form-data" class="form-horizontal"> 
    <div class="form-group"> 
     <label style="padding-left: 153px;" for="ben" class="control-label col-md-4">Upload PAN Register Copy * :</label> 
     <input style="margin-top: 9px; margin-left: 119px;" type="file" class="btn btn-default" id="pancopy" name="file" onchange="return ValidPanRegUpload()" value="Upload PAN" required="required"> 
     <div id="errorBoxImgPan"></div> 
     <div class="col-md-5"> 
      <img class="img-responsive" id="image2_preview"> 
     </div> 
     <div class="col-md-5" id="show_pan_button" style="display:none"> 
      <input style="margin-top: 9px; margin-left: 119px;" class="btn btn-primary" type="submit" value="Upload" name="pancopy_name" id="pancopy_submit" /> 
      <div id="errorBoxSubmitPan"></div> 
     </div> 
    </div> 
</form> 
<input type="submit" id="step-3" name="step-3" onclick="return saveBank();" class="btn btn-primary col-md-2 col-md-offset-5" value="Save"> 
<script> 
    function saveBank() { 
     if ($.trim($("#pancopy").val()) == '') { //there should be only if 
      $("#pancopy").focus(); 
      $("#errorBoxImgPan").removeClass('hide'); 
      $("#errorBoxImgPan").html("Please upload your PAN copy"); 
      return false; 
     } else if ($("pancopy_submit").value != "") { 
      $("#pancopy_submit").focus(); 
      $("#errorBoxSubmitPan").removeClass('hide'); 
      $("#errorBoxSubmitPan").html("Please click the Upload button to upload your PAN copy"); 
      return false; 
     } else if ($.trim($("#copyvat").val()) == '') { 
      $("#copyvat").focus(); 
      $("#errorBoxImgVat").removeClass('hide'); 
      $("#errorBoxImgVat").html("Please upload your VAT copy"); 
      return false; 
     } else if ($("vat_submitcopy").value != "") { 
      $("#vat_submitcopy").focus(); 
      $("#errorBoxVatSubmit").removeClass('hide'); 
      $("#errorBoxVatSubmit").html("Please click the Upload button to upload your VAT copy"); 
      return false; 
     } 
     $.ajax({ 
      url: "seller_bank_save.php", 
      type: "POST", 
      data: postData, 
      success: function(data) { 
       alert(data); 
       /*$("#bank_name").val(''); 
       $('#branch_name').val(''); 
       $('#holder_name').val(''); 
       $("#account_no").val(''); 
       $("#typeacc").val(''); 
       $("#branchcode").val(''); 
       $("#panno").val(''); 
       $("#code_ifsc").val('');*/ 
       $('#new_show').hide(); 
       $('#new_store').hide(); 
       $('#new_bank').hide(); 
       $('#new_product').show(); 
       $('#new2').removeClass('disabled'); 
       $('#new3').removeClass('disabled'); 
       $('#new4').removeClass('disabled'); 
       $('#new2').addClass('active'); 
       $('#new3').addClass('active'); 
       $('#new4').addClass('active'); 
       goToProduct(); 
      } 
     }); 
     return false; 
    } 
</script> 

ok, aber die Upload-Taste, um die Validierung nur einmal nach der Vorschau des Bildes nehmen soll

+0

Hallo. Willkommen bei Stack Overflow. Bitte schau dich um und nimm die [Tour] (http://stackoverflow.com/tour) und lies die [Hilfe]. Sie können auch darüber nachlesen, wie Sie eine Frage stellen können (http://stackoverflow.com/questions/how-to-ask). –

Antwort

0

In erster Linie von SaveBank(), den Sie hinzufügen, zusätzlichen sonst. Entfernen Sie sonst von der ersten Bedingung. Wenn Bedingung immer mit IF, sonst beginnt.

Verwandte Themen