Gravity Forms Read Only Fields

Jan 28, 2021

2 Min. Read

Share URL

This page may contain affiliate links. Please read my disclaimer for more information.

In this article, I’ll show you how to make any input field in your Gravity Forms form read-only, preventing the data in the field from being modified.

The Use Case:

There are several reasons for this solution, however, we needed this solution for a specific project where we built a membership site with Gravity Forms.

When the user signs up for a free trial, we used a hidden field to record the “Enrollment Date”. When their trial is over, they are sent to a subscription form to start their paid subscription. We also use a hidden field in this form to capture their “Subscription Date”.

Those two dates are displayed on the My Account page in a form that the user can use to update their profile information. However, we don’t want the user to modify or change those dates, so we made the fields read only.

Step One

The JavaScript code snippet below is what we will use to create the magic.

Note: This snippet will only work for text input fields, i.e Single Line Text, Name, Email. If you need to make a paragraph field, checkbox field, or radio field read-only, there are some additional code snippets available in this article.

https://gist.github.com/chrisegg/c9a6b650fd96c82c9d66e808a4e7ff0f
  1. Copy the code above
  2. Add an HTML Field to your form
  3. Past the code in the Content area

Step Two

Now that the code is in place, the next step is to add the gf_readonly class to the fields you want to make read-only.

  1. Click on the field you want to edit
  2. Open the Appearance Tab
  3. Add gf_readonly to the Custom CSS Class field

Note: If you already have another class in the field, you can still add another one, just be sure to add a space between the classes.

No Code Method

There is a way to make your fields read-only without messing with code. It requires a third party add-on, but it makes the read-only function available any time and for almost any field.

The Wrap Up

This is a nice solution to have on hand, for when you need it. And it’s one of those things that shows you that Gravity Forms is really capable of a lot more than you think.

If you have questions or need help, feel free to use the comments below.

Photo of author
About the Author
Chris Eggleston
Husband. Father of 4. Grandpa of 2. Chief Problem Solver exploring business systems, technology, AI & faith — helping people solve real problems. @mantiswp @chrisegg

Support Chris - Donate $5

Gravity Wiz Add-Ons

Advertisement

0 0 votes
Article Rating
Subscribe
Notify of
guest
6 Comments
Inline Feedbacks
View all comments
Joanner Algarme
Joanner Algarme
2 years ago

Hi,

Its working well with other fields e.g texarea.

I cant get it to work with datepicker. Can you help. Thanks

FMdC
FMdC
2 years ago

Is it possible to add an exception so that administrators can still edit the field?

Jyoti
4 years ago

Thanks a lot. this was very helpful

Stuart Manning
4 years ago

Really helpful, thanks! Nice and easy to understand & follow

Related Post

How to Secure a Digital Broadcast Page with Gravity Forms Submit to Access Add-On

Live events and webinars are powerful ways to connect with your audience, but hosting them directly on your WordPress site...

Oct 3, 2025

4 min. read

Step-by-Step Guide: Sending a Gravity Forms Notification to the User

Gravity Forms notification feature allows you to send emails to users automatically when they submit a form. This is useful...

Mar 20, 2025

5 min. read

Gravity Forms Multi-Date Picker

Gravity Forms is a powerful form builder, but you might occasionally find some limitations. For example, the date picker field...

Nov 13, 2024

4 min. read

How to Migrate From WS Forms to Gravity Forms: A Step-by-Step Guide

Migrating from WS Forms to Gravity Forms can seem daunting, but with the right approach, it can be a smooth...

Oct 26, 2024

4 min. read

How to Connect Gravity Forms to SendFox: A Step-by-Step Tutorial

This tutorial will walk you through connecting Gravity Forms to SendFox and ensuring your contacts are added to your email marketing...

Oct 16, 2024

5 min. read

How to: Gravity Forms BMI Calculator

Many people don’t realize that the calculation feature is built into the Gravity Forms core plugin and is available for...

Oct 10, 2024

4 min. read