Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="q-app">
  <div class="q-pa-md">
      <div class="q-gutter-md row">
        <q-input
                 v-model.trim="$v.user.username.$model"
                 outlined
                 label="Username"
                 @input="$v.user.username.$touch()"
                 @blur="$v.user.username.$touch()"
                 :error="$v.user.username.$error"
                 :error-message="errorMessage"
                 
                 >
        </q-input>
      </div>
    </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                const { required } = validators
const validationMixin = vuelidate.validationMixin

Vue.use(vuelidate.default)

new Vue({
  el: '#q-app',
  mixins: [validationMixin],

  data () {
    return {
      user: {
        username: '',
      },
    }
  },

  methods: {
    //
  },
  
  computed: {
    errorMessage () {
      let errorMessage = ''
      let vUsername = this.$v.user.username
      if (!vUsername.required && !vUsername.isOdd) {
        errorMessage = 'A username is required and must be an odd number of letters!'
        return errorMessage
         }
      if (!vUsername.required && vUsername.isOdd) {
        errorMessage = 'A username is required.'
        return errorMessage
      }
      if (!vUsername.isOdd && vUsername.required) {
        errorMessage = 'The username must be an odd number of letters'
        return errorMessage
      }
    }
  },

  validations: {
    user: {
      username: {
        required,
        async isOdd (value) {
          if (value.length === 0) return false
          // const response = await fetch('https://api.github.com/users/laravel')
          // console.log(await response.json())
          return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve(typeof value === 'string' && value.length % 2 !== 0)
          }, 350 + Math.random() * 300)
          })
        }
      }
    },
  },
})
              
            
!
999px

Console