All inputs that don't file or submit



  • There's a form, with 10 elements, there's different kinds of inputs, and that's how I can't figure out how to choose the inputs except for the type of file, and submit.

    var cntInp = $('form#lala').find('input[type!="file"]').length;
    console.log(cntInp )// Выводит все инпуты с типами кроме file.
    

    And how do you add to the condition, what else would you throw away the input with the type submit?



  • inputs = Array.from(document.querySelectorAll('input'));
    

    inputs.forEach(function(e, i) {
    if(e.type == 'file' || e.type == 'submit') console.log(e.id, e);
    });

    <input id='1' type='text'>
    <input id='2' type='checkbox'>
    <input id='3' type='radio'>
    <input id='4' type='file'>
    <input id='5' type='hidden'>
    <input id='6' type='password'>
    <input id='7' type='submit'>
    <input id='8' type='button'>
    <input id='9' type='range'>
    <input id='10' type='number'>

    jquery

    inputs = $('input').not(':input[type=file], :input[type=submit]');

    inputs.each((i, e) => {
    console.log(e.id);
    });

    <script src='https://code.jquery.com/jquery-3.1.0.min.js'></script>

    <input id='1' type='text'>
    <input id='2' type='checkbox'>
    <input id='3' type='radio'>
    <input id='4' type='file'>
    <input id='5' type='hidden'>
    <input id='6' type='password'>
    <input id='7' type='submit'>
    <input id='8' type='button'>
    <input id='9' type='range'>
    <input id='10' type='number'>




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2