• Skip to primary navigation
  • Skip to main content

GravityWP

The best information about Gravity Forms, GravityView, Gravity Flow and other addons

  • Tutorials
  • Forms
  • Views
  • Workflow
  • PDF
  • Perks
  • Show Search
Hide Search
Jurriaan Koops

Capitalize fields in Gravity Forms

Jurriaan Koops · Mar 27, 2018 ·

How to capitalize the content of a Gravity Forms input field? There are two possible angles. If you just want to display the content of a field in Uppercase, use the CSS.
If you want to convert the user input to Uppercase while submitting the form, use the PHP solution.

Download Gravity Forms
  1. Capitalize a form field with CSS for visual purpose
  2. Capitalize a form field with PHP before entry
DEMO

Capitalize Demo

  • 4 quarters CSS

  • Fill in a number
  • Gravity Forms - Radio Buttons / Checkbox Images

  • JetSloth - Image Choices

  • Gravity Forms - List

  • Column 1Column 2Column 3Column 4 
  • Gravity Forms - Survey - Stars (rating)

  • GravityWiz - Copy Fields

  • Copy Field

  • Just type something here ;-)
  • Copy Address

  • GravityWiz - Unique ID

  • ovann86 Dropdown List Field

  • Simple dropdownAdvanced dropdown 
    Just click on the '+' sign to add new rows with dropdowns.
  • ovann86 List Field Number

  • US notationEU notationValuta 
  • ovann86 List Field Date

  • Date Format dd/mm/yyyyDate dd-mm-yyyy with IconDefault Date Set yyyy/mm/dd 
  • ovann86 List Field Date

  • Upload 1Upload 2 
  • Slider

  • Perk Word Count

  • Minimal 2 and maximal 6 words.
  • Maximal 144 characters
  • Maximum 1000 characters (default option in GF)
  • GF Survery Ranking

    • First Choice
    • Second Choice
    • Third Choice
    • Fourth Choice
    • Fifth Choice
    • Happy
    • Crazy
    • Not happy
  • GF Survery Likert

  • Strongly disagreeDisagreeNeutralAgreeStrongly agree
  • Strongly disagreeDisagreeNeutralAgreeStrongly agree
    First row
    Second row
    Third row
    Fourth row
    Fifth row
  • Limit Dates

  • Date Format: DD slash MM slash YYYY
    Select your date between today and 1 month ahead. You can only select Tuesdays, Wednesdays and Thursdays in this period. That's what this plugin does, and more. For example you can set fixed dates, ranges from today, etc.
  • Merge tags gravity pdf

  • read-only-fields

  • bar-chart-gravity

  • Not required. We keep you updated about new versions if you fill in your e-mail address here.
  • Please enter a number from 1 to 99.99.
  • Percentage Sign

  • CSS List

    • Check if this is done;
    • Check if that is done;
    • And finally check if everything is done.
  • Gravity Forms Entries in Excel

Capitalize a form field with CSS for visual purpose

First you need the form ID and the field ID. Then add the following code to your CSS. Of course you need to change the Form and Field ID number. The correct CSS selector is '#input_FormID_FieldID'.
#input_6_1 {      /*based on FormID and FieldID*/
    text-transform: uppercase;
}

Capitalize a form field with PHP before entry

First you need the form ID and the field ID. Then add the following code to your functions.php. Of course you need to change the Form and Field ID number.
//Change _6 to the form ID number everywhere
add_action('gform_pre_submission_6', 'capitalize_fields_6');
function capitalize_fields_6($form){
        // add all the field IDs you want to capitalize, to this array
        $fields_to_cap = array('input_6_1');
        foreach ($fields_to_cap as $each) {
                // for each field, convert the submitted value to uppercase and assign back to the POST variable
                // the rgpost function strips slashes
                $_POST[$each] = strtoupper(rgpost($each));
        }
        // return the form, even though we did not modify it
        return $form;
}
Download Gravity Forms

Gravity Forms

© 2021 - This website is made possible by the wonderful services of
WordPress, GravityForms, GravityView, GravityWiz, Genesis Framework & WP Engine

  • About
  • Hire GF developers
  • Charts
  • Cheat Sheet