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

    rules: float type verification but not required

    Framework
    1
    1
    97
    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.
    • I
      itokia last edited by itokia

      Hello,
      I would like to check my float field without making it required.
      I manage to check its type but as soon as I do not inform it it puts me an error.

      <q-input
                filled
                v-model.number="valeur"
                label="Valeur"
                type="number"
                step="any"
                :rules="[champDecimal()]"
              />
      
      methods: {
          champDecimal () {
            return (v) => /^([0-9]+([.][0-9]*)?|[.][0-9]+)$/.test(v) || 'Valeur erronée'
          }
      }
      

      Edit: I tested the regex below to allow the empty chain but it does not work.

      ^([0-9]+([.][0-9]*)?|[.][0-9]+)$|^$
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post