Nice & easy! A great JS Script... I'm keeping the credits, this ain't mine!
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: ArjoGod, Shauna Merritt -->
<!-- Modified By: Ronnie T. Moore, Editor -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
extArray = new Array(".jpg");
function LimitAttach(form, file) {
allowSubmit = false;
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.");
}
// End -->
</script>
And to make it work, just apply it on the submit input
<input type="submit" onclick="LimitAttach(this.form, this.form.input_file_name.value)" />
1 comentarios:
Neta es como si escribieras en chino, no sé ni qué es, ni cómo se come, ni para qué sirve ni nada... Pero se ve chido, eso sí.
Publicar un comentario