Hi, i need to verify that an input file in an html form is an image, i've made the follow code inside the html page, but don't work...
script type="text/javascript" language="javascript"
function valida(f){
var campo = f.immagine.value;
//window.alert(campo);
var er = /^+.[\.]([jpg]|[gif]|[png])$/;
if(er.test(campo)) {
windows.alert("espressione regolare corretta");
return true;
}
else {
windows.alert("espressione regolare non corretta");
f.immagine.style = "color:#F00";
return false;
}
}
/script
...html code...
form onsubmit="return valida(this)" action="inserisci_articolo1.php" enctype="multipart/form-data" method="post">
input type="file" name="immagine" id="immagine" /
/form