Categories

:invalide Selector

Categories: Form

:invalid

Plugin: ep.modify

Description: Selects all input, textarea, select and button elements, witch are invalid.

  • :invalid

    version added: 6.11.0

The :invalid selector basically selects all form controls witch are not valid, the valid state can be set from widgets like the .uiValidate() method.

  • Finds all invalid input elements.

    HTML:
    <form>
      <input type="button" value="Input Button"/>
      <input type="checkbox" />
    
      <input type="file" />
    
      <input type="password" />
      <input type="radio" />
      <input type="reset" />
    
      <input type="submit" />
      <input type="text" />
      <select><option>Option</option></select>
    
      <textarea></textarea>
      <button>Button</button>
    </form>
    
    Code:
    ep(':input')
        .uiValidate({
            required: true
        })
        .trigger('validate');
    
    $('form :invalid');
    
    Results:
    // matched elements
      <input type="checkbox" />
    
      <input type="file" />
    
      <input type="password" />
      <input type="radio" />
      <input type="reset" />
    
      <input type="submit" />
      <input type="text" />
      <select><option>Option</option></select>
    
      <textarea></textarea>