...

View Full Version : file upload type javascript validation



vineet
10-09-2008, 01:46 PM
hi all

i m using this below script to validate the file to be upload if its extension is .jpg, .gif or .doc.

this script works fine in Internet explorer but doesnot work in firefox 3.

can anyone give me an alternative or tell what to add in it.

vineet

<script language="javascript">

function Checkfiles()

{

var fup = document.getElementById('filename');

var fileName = fup.value;

var ext = fileName.substring(fileName.lastIndexOf('.') + 1);

if(ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "doc")

{

return true;

}

else

{

alert("Upload Gif or Jpg images only");

fup.focus();

return false;

}

}

</script>

A1ien51
10-09-2008, 02:29 PM
Did you debug it to see why?

What does var fileName = fup.value; return?

Use Firebug or an alert to see the value

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum