2013-11-26 31 views

回答

0

我也嘗試使用多個文件上傳使用插件,但沒有適當的文檔任何這種預定義的方法。 但在你的情況,而不是檢查0,請嘗試檢查undefined

function validateForm() { 
    var x = document.forms["classifieds"]["file[]"].length; 
    if (x == undefined) { 
     alert('Please select a file'); 
     return false; 
    } 
} 

以下是我與形式進行不同條件提交:

1)在不上傳任何文件,

document.forms["classifieds"]["file[]"].length //returns undefined 

2)對於某些文件

one file uploaded // returns 2 
two files uploaded // returns 3 
and so on 

這裏是fiddle

希望你明白。