f



Need to check file field for content in <cfinput type="file" name="custCartThumb">

With the following code, I get the "message" whether or not there is
content in my filefield:

function check_file_field()
{
var file_field = document.getElementById("custCartFile");
if(file_field.value.length == 0)
{
alert("You are required to select an Image");
return false;
}
else
{
return true;
}
}

<cfinput type="file" name="custCartThumb">
<cfinput type="submit" name="submit" value="Add Image" onClick="return
check_file_field()">

It's like the function does not detect if the cfinput type="file"
contains anything!
Any help is appreciated.
Thanks,
Trint

0
11/15/2006 3:42:22 PM
comp.lang.javascript 38370 articles. 0 followers. javascript4 (1315) is leader. Post Follow

2 Replies
791 Views

Similar Articles

[PageSpeed] 47

trint wrote:

> <cfinput type="file" name="custCartThumb">
> <cfinput type="submit" name="submit" value="Add Image" onClick="return
> check_file_field()">
>
> It's like the function does not detect if the cfinput type="file"
> contains anything!

What is cfinput? It isn't an html tag.

http://www.w3schools.com/tags/default.asp

Peter

0
Peter
11/15/2006 8:09:34 PM
Peter Michaux said the following on 11/15/2006 3:09 PM:
> trint wrote:
> 
>> <cfinput type="file" name="custCartThumb">
>> <cfinput type="submit" name="submit" value="Add Image" onClick="return
>> check_file_field()">
>>
>> It's like the function does not detect if the cfinput type="file"
>> contains anything!
> 
> What is cfinput? It isn't an html tag.
> 
> http://www.w3schools.com/tags/default.asp

It is Cold Fusion Server Side code.

-- 
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
0
Randy
11/16/2006 12:07:35 AM
Reply: