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

    Working with the error property of q-field for validation (Solved)

    Help
    2
    3
    256
    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.
    • mboeni
      mboeni last edited by mboeni

      Hi there

      I would like to act on the state of the ‘error’ property of q-input like this:

          saveAccountDataButtonPressed: function () {
            // Do the saving - The validation is done on the field itself
            if (this.$refs.usernameField.error === false) {
              // this.$q.localStorage.set('username', this.username)
              console.log('No validation errors.')
            } else {
              console.log('There are validation errors.')
              console.log(this.$refs.usernameField.error)
            }
      

      and here is the q-input:

        <q-input
          ref='usernameField'
          outlined
          dense
          dark
          color="accent"
          bg-color="blue-grey-6"
          v-model="username"
          :rules="[ val => username.length >= 3 || 'Please use a minimum of 3 characters.' ]"
        />
      

      My issue now is that ‘error’ is always null instead of the expected boolean value.

      Any ideas why this is?

      Cheers,
      Michael

      1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman last edited by metalsadman

        @mboeni use this.$refs.usernameField.hasError

        mboeni 1 Reply Last reply Reply Quote 0
        • mboeni
          mboeni @metalsadman last edited by

          @metalsadman Thanks, I wasn’t aware that there is a ‘hasError’ too.

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