7

Using this documentation https://docs.joomla.org/Form_field I have developed a plugin and used the showon attribute within the XML (head to the bottom of that page).

Whilst is shows me I can use

showon="foo:1[AND]bar:1" and

showon="foo:1[OR]bar:1"

I would like to showon based on whether a text field is not empty. Is this a possibility or will I require JS?

I have also heard you can do showon="field1!:1" and showon=field!"

Here's my code which shows both fields.

<field
        name="telephone"
        type="text"
        label="MOD_HEADER_CONTACT_TELEPHONE_LABEL"
        description="MOD_HEADER_CONTACT_TELEPHONE_DESC"
        default=""
        class=""
/>
<field
        name="countrycode"
        type="text"
        label="MOD_HEADER_CONTACT_COUNTRY_CODE_LABEL"
        description="MOD_HEADER_CONTACT_COUNTRY_CODE_DESC"
        default=""
        class=""
        required="required"
        showon="telephone!:"
/>
1
  • Hope my answer helps! Jun 28, 2017 at 19:00

1 Answer 1

6

Yes it is possible to do this:

showon="foo!:"
11
  • I tried this and the field shows from the beginning. Is this definitely correct?
    – Eoin
    Jun 28, 2017 at 19:05
  • Yes i tried it. Jun 28, 2017 at 19:11
  • What is the input type? Jun 28, 2017 at 19:12
  • Both text, maybe I should do a code example
    – Eoin
    Jun 29, 2017 at 9:38
  • 1
    Yeah the same code and it works for me, hahaha i understand you the same version and different result :/, thank you and you are welcome Jul 3, 2017 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.