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

    lazy-rules="ondemand" doesnt work when I use external validation

    Help
    2
    3
    776
    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.
    • D
      daep93 last edited by

      I want q-form to trigger external validation function “isUsernamVlid” when I click Login button. However, every time I typed a character in q-input, validation function was triggered. How to fix it?

       <q-form @submit.prevent="submitForm">
            <q-input
              class="q-ma-md"
              outlined
              lazy-rules="ondemand"
              v-model="id"
              label="ID"
              error-message="wrong"
              :error="!isUsernameValid"
            />
            <q-btn
               class="q-ma-md"
               type="submit"
               color="light-blue"
               label="Login"
               :loading="submitting"
            >
            <template v-slot:loading>
                  <q-spinner-facebook />
            </template>
       </q-btn>
      
      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @daep93 last edited by

        @daep93 said in lazy-rules="ondemand" doesnt work when I use external validation:

        isUsernameValid

        a bit of a workaround:
        you could check inside the !computed! property isUsernameValid if the login button has been pressed before( with a data.hasFormSubmitted boolean in data for example), if not !data.formSubmitted then always return true in isUsernameValid ( no errors will be shown until you press the submit button).

        In addition when you change the input value set data.formSubmitted = false again.

        D 1 Reply Last reply Reply Quote 0
        • D
          daep93 @dobbel last edited by

          @dobbel Thank you your advice. I think your approach looks good but the suggested way is not fundamental solution for usage of lazy-rules. It will check validation when I would type a character in input box. It means, anyway, lazy-rules=“ondemand” still not work.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post