No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Deactivate QInput rules if QInput is disabled.

    Help
    1
    2
    973
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Bafian last edited by

      Hi everyone from Chile!
      Maybe someone could help me.
      So I have this QForm and I have some social media q-input links where you have to click on a checkbox to enable the input before inputting your link.
      On each input, I validate the input with a regex to make sure it contains “http” or “https” in it.

      The thing is, if i don’t enable the input, on submit If i validate the form it will validate also the “disabled” inputs that have no content.

      Example:

                <q-input
                  square
                  outlined
                  ref="facebook"
                  label="FACEBOOK"
                  placeholder="https://wwww.facebook.com/username"
                  class="q-pb-lg custom-field-checkbox"
                  bg-color="white"
                  v-model="data.facebook.link"
                  :disable="!data.facebook.enable"
                  :rules="[val => val.match(/^(http|https):\/\/(.*)/) || 'Incorrect Link format']"
                  lazy-rules
                />
      

      Where if “data.facebook.enable” is true, I would like to trigger the rules.

      I know some workaround, but I wanted to know if there is an easier way to solve this. Also, add, this is a child component of the overall form.

      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • B
        Bafian last edited by

        This was quickly solved by someone in Discord (Jeff Galbraith)
        The solution was this one if anyone ever finds itself in the same seat:

                  <q-input
                    square
                    outlined
                    ref="youtube"
                    label="YOUTUBE"
                    class="q-pb-lg custom-field-checkbox"
                    bg-color="white"
                    v-model="data.youtube.link"
                    :disable="!data.youtube.enable"
                    :rules="[val => data.youtube.enable !== true ? true : val.match(/^(http|https):\/\/(.*)/) || 'Incorrect Link format']"
                    lazy-rules
                  />
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post