jaymc Posted December 23, 2006 Share Posted December 23, 2006 When submitting a form with a type=FILE field, how can I use javascript to validate whether that file field has a location in itIn other words, that someone has clicked browser and selected a file...The standard [b] else if ( document.form.picture.value == "") {do blarrrr}[/b] doesnt appear to be working..Any help would be great!Thanks! Quote Link to comment Share on other sites More sharing options...
emehrkay Posted December 23, 2006 Share Posted December 23, 2006 take away the submit button. put in a regular button with onclick="func();"function func(){if(document.getElementById('form_field_id').value == ''){alert('blah');}else{document.getElementById('form_id').submit();}} Quote Link to comment Share on other sites More sharing options...
jaymc Posted December 24, 2006 Author Share Posted December 24, 2006 Cheers, worked fine! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.