function isImg(str)
{
if(str.search("[.]+(jpg|jpeg|swf|gif|png|JPG|JPEG|SWF|GIF|PNG)$"))
{
return false;
}
return true;
}
// 截取url後面的檔案類型
function getUploadUrlSuffix(urlStr){
var url = urlStr.substring(urlStr.lastIndexOf("\."),urlStr.length);
return url;
}
var img = $("#img").val();
if (img == '') {
msgBox = document.getElementById("chenkimg");
msgBox.innerHTML = "請選擇上傳圖檔!";
return false;
}
if(isImg(getUploadUrlSuffix(img))){
return true;
}else{
msgBox = document.getElementById("chenkimg");
msgBox.innerHTML = "隻能上傳圖檔格式的(jpg|jpeg|swf|gif|png)";
return false;
}