You are viewing limited content. For full access, please sign in.

Question

Question

Get timestamp when a form is signed

asked on August 6, 2015

I am looking for a way to capture the time once a signature is signed via signature field.  I used the code found here to do this and manipulated it to watch the 'Sign' button found in the signature display (See code below), but now I'm looking to accomplish this with multiple signatures on a page.  I found that the 'Sign' Button has a class of "btn btn-primary signature-btn signSignatureBtn" but if I sign the form using the 2nd signature field, it applies a new time stamp to the original field(timeIn).  Any ideas on how to differentiate between the two buttons signature fields?  The use case is for a shipping document - The shipper needs to sign upon arrival (timeIn) and the carrier needs to sign upon departure (timeOut).  

//Sign-Time
$(document).ready(function () {
  $('.signSignatureBtn').click(timestamp);
 
  function timestamp() {
    
    var d = new Date();
    var minutes = d.getMinutes();
    
    if (minutes < 10) {var minutes = "0" + minutes;}
        
    if (d.getHours() < 12) { var a = "AM";}
    else {var a = "PM";}
      
    if ($(this).hasClass('signSignatureBtn')) {
      $('.timeIn input').val(d.getHours() + ":" + minutes + a);
    }
    
    else {
    
    $('.timeOut input').val(d.getHours() + ":" + minutes + a)
    
    }
  }
});
//End Sign time

 

0 0

Answer

SELECTED ANSWER
replied on August 6, 2015

Hello, 

 

Here is a solution 

//Sign-Time
$(document).ready(function () {
  var sigName = "";
  
  $('.shipper').click(function() {
  	sigName = "Shipper";
  });
  
  $('.driver').click(function() {
  	sigName = "Driver";
  });
  
  
  $('.signSignatureBtn').click(timestamp);

 
  function timestamp() {
    
    var d = new Date();
    var minutes = d.getMinutes();
    
    if (minutes < 10) {var minutes = "0" + minutes;}
        
    if (d.getHours() < 12) { var a = "AM";}
    else {var a = "PM";}
      
    if (sigName == "Shipper") {
      $('.timeIn input').val(d.getHours() + ":" + minutes + a);
      sigName = "";
    }
    
    else {
    
    $('.timeOut input').val(d.getHours() + ":" + minutes + a)
    sigName = "";
    }
  }
  
  
});
//End Sign time

.shipper is the class name of your Shipper Signature and .driver is the class name of your Driver Signature. 

1 0

Replies

replied on August 6, 2015

Thanks Winston!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.