• Resolved JohnJay

    (@jjacoberger)


    Is there any way to format the name entered on a form to be initial caps? The name entered in the form should be initial caps in the display form as well as in e-mails that are generated when the form is submitted. I can use text-transform to make the on-screen form display, but e-mails are not formatted.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @jjacoberger !

    Hope you’re doing great today!

    Indeed, the CSS option will only change how the text is displayed, not the underlying text itself. This will need to be done using JS instead.

    Please try the following snippet:

    <?php
    
    add_action('wp_footer', function() {
    ?>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
      $('#forminator-module-645 #forminator-field-name-1').on('keyup', function() {
        var s = $('#forminator-module-645 #forminator-field-name-1').val();
    
        s = s[0].toUpperCase() + s.slice(1);
    
        $('#forminator-module-645 #forminator-field-name-1').val(s);
      });
    });
    </script>
    <?php }); 

    Important part here is to change the #forminator-module-645 selector to one that matches your form’s ID. You can find the ID in the form’s edit screen’s URL or in the shortcode.

    To install:
    – place the correct form ID in the shared code
    – copy the above code to a .php file with any name
    – upload the .php file to /wp-content/mu-plugins/ directory (create it if it doesn’t exist)

    Best regards,
    Pawel

    Thread Starter JohnJay

    (@jjacoberger)

    Awesome! Thank so so much Pawel.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Format name with initial caps’ is closed to new replies.