Javascript Validation of File Field

They have: 330 posts

Joined: Apr 2000

When validating a text field I know I am looking for value.length > 0 which is fine. When I am trying to validate a File field using the same method it always returns true because it already has some value.

How would I create a validation to ensure something is being selected in a file field?

Thanks for any help.

Art

They have: 84 posts

Joined: Jun 2001

Try this:

if (form.text.value == '') {
alert('You did not enter anything!')
}

They have: 330 posts

Joined: Apr 2000

The problem is it always passes something through the form because it's not only a text box but also a submit button which combined creates the input type File.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.