This.Sven This.Sven - 6 months ago 12
jQuery Question

JavaScript .not ignores the parameters

I want to validate all my inputs except the file uploader input. If I use

.not($( "#uploader" ))
it does ignore anything below I've written.

html:

<section>
<div id="formularDiv" class="sampleFormStyle">
<div class="wrapper">
<h2><?php echo 'You\'re applaying for '.strtoupper($_GET['page']);?></h2>
<form id="formularID">
<input id="firstName" name="firstName" type="text" placeholder="First Name:"/>
<input id="lastName" name="lastName" type="text" placeholder="Last Name:"/>
<input id="street" name="street" type="text" placeholder="Street:"/>
<input id="postalCode" name="postalCode" type="text" placeholder="Postal Code: " />
<input id="place" name="place" type="text" placeholder="Place: "/>
<input id="telefone" name="telefone" type="text" placeholder="Telefone: " />
<input id="email" name="email" type="email " placeholder="Email: "/>
<textarea></textarea>
<label id="uploader" for="uploadFile"><i class="fa fa-cloud-upload fa-2x fa-fw" aria-hidden="true">Upload</i></label>
<input id="uploadFile" name="uploadFile" type="file"/>
<input id="submitForm" name="submitForm" type="submit" value="Submit"/>
</form>
</div>
</div>
</section>


JavaScript:

$('#formularID').submit(function() {
$(":input").not('#uploader').each(function(){
//some code that's working without .not()
});
})


I appreciate every help!

Answer

Try this. As per your html, the id of the input that you want ignore is uploadFile not uploader

$('#formularID').submit(function() {
            $("input:not(#uploadFile)").each(function(){
                 //some code that's working without .not()
            });
    })
Comments