P
Pavan Jha
Hi,
I am using File Input for one of my pages. I have multiple inputs on
my page as
<INPUT Type=FILE Name=File1>
<INPUT Type=FILE Name=File2>
and so on...
I have a function for validating filetype which is called on onChange
of File
<INPUT Type=FILE Name=FILE1 onchange='return
validatefiletype(document.MyForm.FILE1)'>
take a look at the code snippet below for validatefiletpye
function validateFileType(thisvalue){
var i;
var ufilename;
if (thisvalue.value.length > 0 )
{
ufilename = thisvalue.value.toUpperCase();
var extnarr = ufilename.split(".");
fileType = "." + extnarr[extnarr.length-1];
if (fileType == ".GIF")
{
thisvalue.value = thisvalue.value.toString();
return true;
}
else
{
alert("Only the GIF files are allowed for uploading");
thisvalue.value = "" ;
return false;
}
}
}
Now on to the problem..
The script runs and works fine till the alert part.. means it does
flash alert when it finds the wrong format (anything but gif) has been
chosen for upload... but it doesn't perform the next two steps of
clearing the File Text box which now shows the selected file name (of
a non supporting extension, which should be cleared as soon as it
finds its unacceptable)..
Can any one tell the reason of this behaviour and how to get it
working..
thanks
p1j
I am using File Input for one of my pages. I have multiple inputs on
my page as
<INPUT Type=FILE Name=File1>
<INPUT Type=FILE Name=File2>
and so on...
I have a function for validating filetype which is called on onChange
of File
<INPUT Type=FILE Name=FILE1 onchange='return
validatefiletype(document.MyForm.FILE1)'>
take a look at the code snippet below for validatefiletpye
function validateFileType(thisvalue){
var i;
var ufilename;
if (thisvalue.value.length > 0 )
{
ufilename = thisvalue.value.toUpperCase();
var extnarr = ufilename.split(".");
fileType = "." + extnarr[extnarr.length-1];
if (fileType == ".GIF")
{
thisvalue.value = thisvalue.value.toString();
return true;
}
else
{
alert("Only the GIF files are allowed for uploading");
thisvalue.value = "" ;
return false;
}
}
}
Now on to the problem..
The script runs and works fine till the alert part.. means it does
flash alert when it finds the wrong format (anything but gif) has been
chosen for upload... but it doesn't perform the next two steps of
clearing the File Text box which now shows the selected file name (of
a non supporting extension, which should be cleared as soon as it
finds its unacceptable)..
Can any one tell the reason of this behaviour and how to get it
working..
thanks
p1j