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! Link to comment https://forums.phpfreaks.com/topic/31652-solved-when-submitting-a-form/ 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();}} Link to comment https://forums.phpfreaks.com/topic/31652-solved-when-submitting-a-form/#findComment-146727 Share on other sites More sharing options...
jaymc Posted December 24, 2006 Author Share Posted December 24, 2006 Cheers, worked fine! Link to comment https://forums.phpfreaks.com/topic/31652-solved-when-submitting-a-form/#findComment-147135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.