Validating text fields based on value in file input field

Validating text fields based on value in file input field

Relative jQuery noob here, so be gentle!

In a form allowing user uploads of an image, I'm trying to make two fields ("picturebyline" and "picturecaptionheading") required IF there is a value in the field "picture", which is a file input field. (Allows users to browse and select a local image for upload). Using jquery.validate, of course.

The code that follows is what I thought would work, but does not. Any pointers?

  1. $(document).ready(function(){
        $("#StorySubmit").validate({
      rules: {
        title: {
          required: true,
          maxlength: 75,
          minlength: 5
        },
        picturecaptionheading: {
            required: "#picture:filled",
            maxlength: 75,
            minlength: 5
        },
        picturebyline: {
            required: "#picture:filled",
            maxlength: 50,
            minlength: 5
        }
            
              }
        });
    });























Thanks!

- jr