View Single Post
Old 03-27-2005, 09:22 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
javascript: check if file input is undefined

I need to check if a file input box is undefined, but I can not get this to work.

If I alert(document.lform.logoimage.value); , it pops up: "undefined"

So I have tried to evaluate that field to "undefined" and "", and neither work.

so how can I check if a file is not there? i only want this confirmation box to pop up if the user has chosen a file to upload. ( there are other text elements on the form )
HTML Code:
<Script language="JavaScript">
<!--
function verifyLogo(){
  
  if( document.lform.logoimage.value !=  "" ){
    var c = confirm("Are you sure you want to replace the logo image?\nThe current image will be deleted.");
    if( c ){
      return true ;
    }else{
      return false ;
    }
  }
  return true ;
}
-->
</script>
__________________
Mike
sde is offline   Reply With Quote