Quindi ricapitalondo tu diresti di fare così:
Infatti funziona. Sei un GRANDEEEEEEEEEEcodice:<script type="text/javascript"> <!-- function valida() { if (document.Modulo.campo_foto1.files.length === 0) return false; const re = /^[a-zA-Z0-9_. -]+$/; const str = document.Modulo.campo_foto1.files[0].name; if (re.test(str)) { document.Modulo.action = "carica_FOTO1.asp"; document.Modulo.submit(); } else { alert("CARATTERI SPECIALI NON AMMESSI. \n RIMUOVILI E RIPROVA."); return false; } } --> </script> <form method="post" name="Modulo" enctype="multipart/form-data"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <input name="campo_foto1" type="file" required class="label"> <input name="hiddenId1" type="hidden" id="hiddenId1" value="<%=request.QueryString("Col2")%>"> <input name="hiddenData1" type="hidden" id="hiddenData1" value="<%=Dat%>"> <input type="button" value="Invia" class="bottoniscansiona" title="IMPORTA FOTO" onclick="valida();"> </td> </tr> </table> </form>
Grazie