In this guide, we will explain how to display a date field if a signature is captured.
Drag and drop a Signature, a JavaScript, and a Date field.
Click the pencil icon of the JavaScript field and paste the code. Save the changes.
Please use the below code:
// Set signature field id
var signature_field_id = '4dcb-ebe8-4c75';
// Set date field id
var date_field_id = '65e3-a2d3-e401';
// Hide the date field initially
$( '#component-' + date_field_id ).hide();
// Listen to the signature pad event
$( '#component-' + signature_field_id + ' .pad' ).on( 'touchmove click', function( e ) {
// Check if the signature field value
if ( formyoula.form_fields[ 'Signature Input' ].get( 'value' ) ) {
// Show the date field
$( '#component-' + date_field_id ).show();
}
} );
// On click of the signature clear button
$( '#component-' + signature_field_id + ' .type_clear' ).on( 'click', function() {
// Reset the value of the date field
formyoula.form_fields[ date_field_id ].set( {
value: ''
} );
// Hide the date field
$( '#component-' + date_field_id ).hide();
} );
Note: Please change the Component Ids according to your form.
Try the form.
The Date field will be displayed if the Signature is captured.
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂