untitled
untitled

Reputation: 1127

jquery file upload plugin submits whole form

I'm using jquery file upload plugin with <input type="file"> tag in form. Form also has other fields but they are not for submitting to server. Is it possible to upload only file and not the whole form? I am using jquery validator plugin so after uploading a file, form submit is triggered and all empty field are marked as not valid. I could move away <input type="file"> from form but I need it inline between other form elements. Form is dynamic so I don't want to position it absolutely.

Upvotes: 1

Views: 907

Answers (2)

Maug Lee
Maug Lee

Reputation: 915

Here you can find info about formData option:

If you set the formData option, these fields won't be sent to the server...

So you can set it to empty array and rest form fields will not be sent, only files:

$('#foo').fileupload({
    ...,
    formData: [],
    ...,
});

Upvotes: 4

Joke_Sense10
Joke_Sense10

Reputation: 5402

You can go with HTML5 New Form Attribute called 'novalidate' Attribute. It specifies that the form-data (input) should not be validated when submitted.

Example:

<form action="demo.php" novalidate>
E-mail: <input type="email" name="user_email">
<input type="submit">
</form>

Here in the above html code the input field is not validated and the data is submitted successfully.

Upvotes: 0

Related Questions