artmem
artmem

Reputation: 367

Make form fields required only if a file is not attached/uplodad?

I have a page with a job application form where users can fill in their contact info, and then either upload a resume document, or fill out the rest of the form.

The problem is, I need to make certain fields required only if there is no resume attached. Splitting it into separate forms is not an option.

Is there a way to use javascript to require certain fields only when there is no resume attached?

Or alternatively, to automatically fill in the required fields with "See Resume" when a user attaches the resume file?

Upvotes: 0

Views: 65

Answers (1)

Ray Nicholus
Ray Nicholus

Reputation: 19890

You can bind a change handler to the file input element and update the required fields like so:

$('#myFileInput').change(function() {
   $('.myRequiredField').val("See Resume");
});

Upvotes: 1

Related Questions