I added a Date field after a signature field and need to populate the date field with the date the user signs the signature field. I saw this example here on answers and well it just confused me. Can someone share the simple script I need to accomplish this? Thank You
Question
Question
Answer
SELECTED ANSWER
replied on September 27, 2019
If you have a date field named "date signed" that is read only with default value set to "current_date", and that field doesn't exist on any earlier forms in your process, and the signature field is required, you'll basically get the functionality needed to make this work, without having to do any scripting.
That being said - here's a simple script that will populate a date field when the signature field is clicked. It's far from perfect because it could overwrite the date if the field is clicked at a later date in the process, and it also does not clear the date if the signature is removed.
$(document).ready(function () { //when the signature field (with CSS Class of signatureDateTest) is clicked //the current date is populated into the date field (with CSS Class of dateSignedTest) $('.signatureDateTest input').click(function(){ var myDate = new Date(); var m = myDate.getMonth()+1; //month (add 1 because JS defaults months 0-11) var d = myDate.getDate(); //day of the month var y = myDate.getFullYear(); //4-digit year $('.dateSignedTest input').val(m + '/' + d + '/' + y); }); //end of: $('.signatureDateTest input').click(function(){ }); //end of: $(document).ready(function () {
1
0
Replies
You are not allowed to reply in this post.
You are not allowed to follow up in this post.