How to Add Placeholder Text Inside a Field and Indicate if It's Required in Gravity Forms

Hi everyone,

I’m trying to add default text inside a field, like a placeholder, to give users a hint of what should go there (e.g., the word “Message” inside a text area). I can hide the label above the field, but I still want users to see the word ‘Message’ inside the text area. Ideally, this placeholder text should disappear as soon as they start typing.

However, I’ve encountered an issue: while Gravity Forms allows placeholder text, it doesn’t seem to show whether a field is required or not when using this method.

Is there a way to have placeholder text inside a field and still indicate if it’s required (perhaps through some styling or another solution)?

I’d appreciate any insights or suggestions!

Thanks!

Hi,

I’ve tested a new, fresh form, and it shows the required field error message if I submit the form without filling in those fields. Please check the screenshot below and let me know if I’m missing anything.

Hi,

Thank you for your response. I should have clarified what I’m looking for. Currently, I’ve manually added the ‘*’ in the placeholder text to indicate required fields. As you can see in the attached picture, these asterisks aren’t colored. I’m wondering if there’s a way to show that a field is required within the input field itself, with the indicator colored, so I don’t have to add these markers manually.

Screenshot_33

It looks like you can change the color of the placeholder but it would be for all the text, not just the asterisk.

As for auto-appending an asterisk to placeholders for required fields, here’s a snippet:

function gw_required_placeholder_asterisk( $form ) {
	foreach ( $form['fields'] as &$field ) {

		// Skip fields that don't support placeholders
		if ( ! is_callable( [ $field, 'get_entry_inputs' ] ) ) {
			continue;
		}

		// Single input fields
		if ( is_array( $field->inputs ) ) {
			$inputs = $field->inputs;
			foreach ( $inputs as &$input ) {
				if ( $field->isRequired && isset( $input['placeholder'] ) ) {
					$input['placeholder'] = gw_append_asterisk( $input['placeholder'] );
				}
			}
			$field->inputs = $inputs;
		} else {
			if ( $field->isRequired && isset( $field->placeholder ) ) {
				$field->placeholder = gw_append_asterisk( $field->placeholder );
			}
		}
	}
	return $form;
}

function gw_append_asterisk( $text ) {
	// Avoid double-adding an asterisk
	if ( substr( $text, -1 ) !== '*' ) {
		$text .= ' *';
	}
	return $text;
}