I’m using the jQuery Validation Plugin (http://docs.jquery.com/Plugins/Validation/) and I need to make a form.
UPLOAD: <input type="file" name="image" /><br>
URL: <input type="text" name="images">
How do I make it so that at least one of these fields must be filled (i.e. class="required")?
What you’re looking for is called a dependency-expression in jQuery Validate. If your form looks like what you showed (i.e. 2 inputs, one named
imagethe other namedimages) you can do this:So what happens is that when it goes to validate each form field, it checks the given expression, and if it returns true, then the current form field is required. If it’s false, then it’s not.