Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook allows you to add javascript to the footer of your form. You can also add javascript in your form Settings → Customize HTML in the before or after fields.
Usage
add_action('frm_entries_footer_scripts', 'set_custom_limit', 20, 2); function set_custom_limit($fields, $form)
Parameters
- $fields (array)
- $form (object)
Examples
Add javascript to your form
add_action('frm_entries_footer_scripts', 'set_custom_limit', 20, 2);
function set_custom_limit($fields, $form){
if($form->id != 5) return; //change 5 to the ID of your form
?>
//add javascript here
<?php
}
Limit the number of characters
Use this code to limit the maximum number of characters accepted in a field.
add_action('frm_entries_footer_scripts', 'set_custom_limit', 20, 2);
function set_custom_limit($fields, $form){
if($form->id != 5) return; //change 5 to the ID of your form
?>
jQuery(document).ready(function($){
$('#field_FIELDKEYHERE').change(function(){
if($(this).val().length > 15)
$(this).val($(this).val().substr(0, 15));
});
});
<?php
}