function LimitAttach(form, file) {
allowSubmit = false;
extArray = new Array(".gif", ".jpeg", ".jpg", ".png");
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) form.submit();
else
alert("Please only upload files that end in types: " + (extArray.join(" ")) +
"\nPlease select a new file to upload and submit again.");
}
Place "imageUpload" without the quotes in the ID of the File Upload Control
properties.
Found this from a JavaScript.internet.com:
function LimitAttach(form, file) { allowSubmit = false; extArray = new Array(".gif", ".jpeg", ".jpg", ".png"); if (!file) return; while (file.indexOf("\\") != -1) file = file.slice(file.indexOf("\\") + 1); ext = file.slice(file.indexOf(".")).toLowerCase(); for (var i = 0; i < extArray.length; i++) { if (extArray[i] == ext) { allowSubmit = true; break; } } if (allowSubmit) form.submit(); else alert("Please only upload files that end in types: " + (extArray.join(" ")) + "\nPlease select a new file to upload and submit again."); }
Place "imageUpload" without the quotes in the ID of the File Upload Control properties.
Place the following in the onClick:
LimitAttach(this.form, this.form.imageUpload.value)