Skip to main content
August 11, 2021
Question

How to change the text color of a text field

  • August 11, 2021
  • 8 replies
  • 2 views

Hi!

I am new to using the tool and I want to know how I can change the background or the letters of a text field to red in a form. When the text field has an incorrect value.

Where can I put this code, in the header, in the validations?

Example: 

    8 replies

    selvakumark
    Participating Frequently
    August 11, 2021

    Hi [mention:6fec399f2c2344cdb752bc04dc23711a:e9ed411860ed4f2ba0265705b8793d05],

    You can give the text in the validation part of the text field. Below link provides a sample of how to validate and show the message in the field. Note that adding validation to a field, will only show the text in red color and we cannot change the background.

    https://docs.appian.com/suite/help/21.2/recipe-add-multiple-validation-rules-to-one-component.html

    August 11, 2021

    Thanks a lot, Selvakumar

    The form will already be pre-filled for the user, if information is missing in any text field, a message should be displayed requesting its filling immediately, not when submitting

    selvakumark
    Participating Frequently
    August 11, 2021

    If that's the case, then you can try using the card layout suggested by Acacio. If the value is null for the field, you can show the card layout with information.

    acaciob0002
    August 11, 2021

    Hi Maria,

    As Selvakumar mentioned you can not achieve that with the default text field validation, however  you you can 'fake' it with a card layout.

    Simply put a richTextField inside a card layout, and you'll be able to customise the colours.

    a!cardLayout(
      style: "#e74c3c",
      contents: a!richTextDisplayField(
        align: "CENTER",
        value: "This is some text"
      )
    )

    Hope that helps

    Acacio B

    August 11, 2021
    Thank you very much, Acacio

    Check the card layout. The code creates the following image




    I put it in the text field validation but it doesn't work.




     

    if (isnull(ri!codigo_cliente),

    a!cardLayout(

      contents: a!richTextDisplayField(

        value: "Debe ingresar el codigo del cliente",

        align: "LEFT"

      ),

      style: "#e74c3c"

    ), null)



    acaciob0002
    August 11, 2021

    Hey Maria, 

    You should not add the cardlayout in the validation of the textfield, you can leave the validation of the text field triggers but without message, than add the cardlayout as a new component below the text field, you can add the same condition in the show when of the cardlayout so it will only be displayed when the date is missing.

    Regards,

    Acacio B