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!:"
/>
  • Hope my answer helps! – TheNextStage Jun 28 '17 at 19:00
4

Yes it is possible to do this:

showon="foo!:"
  • I tried this and the field shows from the beginning. Is this definitely correct? – Eoin Jun 28 '17 at 19:05
  • Yes i tried it. – TheNextStage Jun 28 '17 at 19:11
  • What is the input type? – TheNextStage Jun 28 '17 at 19:12
  • Both text, maybe I should do a code example – Eoin Jun 29 '17 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 – TheNextStage Jul 3 '17 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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