This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcAge($dob,$age){ | |
$dob.on('change', function() { | |
var dobary = $(this).val().split('/'); | |
var dobobj = new Date(dobary[2], dobary[0]-1, dobary[1]), birthday = { year: dobobj.getFullYear(), month: dobobj.getMonth(), date: dobobj.getDate() }; | |
var todayobj = new Date(), thisyear = todayobj.getFullYear(); | |
var thisYearsBirthday = new Date(thisyear, birthday.month-1, birthday.date); | |
var age = thisyear - birthday.year; | |
if(todayobj < thisYearsBirthday){ age--; } | |
$age.val(age); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this converts Simple Text field to month & year field. change month_year to acctual field name. | |
function ff_month_year_field( $data, $form ){ | |
if( $data['attributes']['name'] === 'month_year' ){ | |
$data['attributes']['type'] = 'month'; | |
} | |
return $data; | |
} | |
add_filter( 'fluentform_rendering_field_data_input_text', 'ff_month_year_field', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ff_address_custom_format( $data, $form ){ | |
$fields = $data['fields']; | |
// change the order of array below for your country | |
$data['fields'] = array( | |
'country' => $fields['country'], | |
'zip' => $fields['zip'], | |
'state' => $fields['state'], | |
'city' => $fields['city'], | |
'address_line_1' => $fields['address_line_1'], | |
'address_line_2' => $fields['address_line_2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change field_name to actual field name. | |
function ff_avoid_autocomplete( $data, $form ){ | |
if( $data['attributes']['name'] === 'field_name' ){ | |
$data['attributes']['autocomplete'] = 'new-password'; | |
} | |
return $data; | |
} | |
add_filter( 'fluentform_rendering_field_data_input_text', 'ff_avoid_autocomplete', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ff_address_add_datalist_attr( $data, $form ){ | |
if( $data['attributes']['name'] == 'address[state]' ){ | |
$data['attributes']['list'] = 'state-list'; | |
} | |
return $data; | |
} | |
add_filter( 'fluentform_rendering_field_data_input_text', 'ff_address_add_datalist_attr', 10, 2 ); | |
function ff_add_state_datalist( $html, $data, $form ){ | |
if ( $data['attributes']['name'] === 'address[state]' ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Enter this configuration to Advanced Date Configuration of Date field. change 01/01/1950 to any date. the date is US format. */ | |
{ | |
onOpen: [function(selectedDates, dateStr, instance){ | |
if (dateStr == '') { | |
instance.jumpToDate('01/01/1950', false); | |
} | |
}], | |
/* Set minimum age.(= 18) delete if you don't limit the age */ | |
maxDate: (new Date().getMonth() + 1) + "/" + new Date().getDate() + "/" + (new Date().getFullYear() - 18) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('fluentform_response_render_input_checkbox', function ($value, $field, $formId, $isHtml) { | |
if ( $formId === 3 ) { | |
$value=''; | |
foreach ( $field['raw']['settings']['advanced_options'] as $fv ) { | |
$value .= '<li>' . $fv['value'] . '</li>'; | |
} | |
if( $value !== '' ){ | |
$value = '<ul style="white-space: normal;">' . $value . '</ul>'; | |
} | |
} |