The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Simple Field Calculations
I need to take the last 4 digits of a number entered into a field and put it into a hidden field.
I have created a standard text field for a social security number to be entered with the following formatting 999-99-9999.
I am looking for some help or guidance on how to take the last 4 digits from this field and place it into a hidden field.
Any guidance and direction would be greatly appreciated.
Thanks in advance.
February 23, 2018 at 6:23 am
This jQuery snippet will work:
jQuery(document).ready(function ($) {
"use strict";
/* change the xxxx to the id of the text field */
$("#field_xxxx").on('change', function() {
/* store last 4-digits in hidden field */
$("#field_yyyy").val( $(this).val().substr(-4, 4) );
});
});
Change field_xxxx to the field id of your text field. Change field_yyyy to the id of your hidden field. Copy the snippet into the after fields area on your form's settings/customize HTML page.
February 23, 2018 at 6:24 am
In the snippet above, make sure you wrap it in the script tags. They tags disappeared when the post was saved.
February 23, 2018 at 7:31 am
Thank you for the insight. I am new to this whole formidable form thing. If you don't mind me asking, where precisely do I place the jquery?
I'm sure my web guy could figure this out, but I'm trying to learn some of this myself for future use.
Thanks in advance.
February 23, 2018 at 7:37 am
Like I said in my post: "Copy the snippet into the after fields area on your form's settings/customize HTML page."
February 25, 2018 at 7:37 pm
Worked like a charm. Thank you for your help on this :)
Discussion closed.