In this example guide, we will explain how to extract part of a number from the input and set it as another field value.
When a user enters a number value in the first field, the second field will extract and show a part of the first field's input value from position number three to eight.
Drag and drop a Number, a Text and a JavaScript field. And rename the fields as shown below.
Click the pencil icon of the JavaScript field and paste the code. Save the changes.
Please use the below code:
// Listen to Formyoula field changes based on label
window.formyoula.form_fields[ 'Number Field' ].on( 'input:set:success', function( field ) {
// Set the number field value to subset
window.formyoula.form_fields[ 'Part Of Number Input' ].set( {
value: this.get( 'value' ).substring( 2, 8 )
} );
} );
Try the form.
The second field will show the value of position numbers three to eight from the input value of the first field.
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂