Ciao a tutti,
utilizzo uno script per validare i campi di un form che per funzionare deve avere come bottone un type=botton, intanto se metto type=button al posto di type=submit quello che ho nell'istruzione OnSubmit non mi funziona più
questa è la pagina in questione:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<SCRIPT LANGUAGE="JavaScript">
<!--
function DoSubmit(obj) {
var Dato1 = obj.Dato1.value;
var strIllegalChars = /[\(\)\<\>\;\:\\\*\+\=\"\[\]]/;
var submitform = true;
var error = '>>> MODULO MODIFICA -------------------------------------\n\n';
error += ' Attenzione : \n\n';
if (Dato1.length < 3) {
error += ' > Nome è un campo obbligatorio \n';
submitform = false;
}
if (Dato1.length > 20 ) {
error += ' > Nome può contenere massimo 20 caratteri \n';
submitform = false;
}
if (Dato1.length > 1 && Dato1.match(strIllegalChars)) {
error += ' > Nome contiene caratteri non consentiti \n';
submitform = false;
}
if (submitform) {
obj.submit();
}
else {
error += '\n--- Fine Controllo ---\n\n';
alert (error);
return false;
}
}
-->
</script>
</head>
<body>
<form name="selecter5" method="POST" action="name.asp" OnSubmit="d=document.Prova.document.selecter5;this .Marchio.value=d.Select1.options[d.Select1.selectedIndex].value;this.Categoria.value=d.Select2.options[d.Select2.selectedIndex].value;">
<table border="1" width="600">
<tr>
<td>
<table border="0" width="500" id="table1" cellpadding="0">
<tr>
<td width="95">Campo 1</td>
<td width="341">
<input type="text" name="Dato1" size="20" style="font-family: Arial; font-size: 8pt; border-style: dotted; border-width: 1px; padding-left:2px; padding-right:2px; width:200; height:18"></td>
</tr>
<tr>
<td width="95">Campo 2</td>
<td width="341">
<input type="text" name="Dato2" size="20" style="font-family: Arial; font-size: 8pt; border-style: dotted; border-width: 1px; padding-left:2px; padding-right:2px; width:200"></td>
</tr>
<tr>
<td width="436" colspan="2">
<iframe id ="ProvCom" name="Prova" src="Dato3.asp" frameborder="0" marginwidth="100" marginheight="0" scrolling="no" width="426" height="54"></iframe></td>
</tr>
<tr>
<td width="95"></td>
<td width="341">
<input name="Submit" type="submit" id="Submit" value="Invia" onclick="DoSubmit(this.form)">
</td>
</tr>
</table>
<p style="margin-top: 0; margin-bottom: 0"></p>
<p style="margin-top: 0; margin-bottom: 0"></td>
</tr>
</table>
<input type="hidden" name="Categoria" value="">
<input type="hidden" name="Marchio" value="">
</form>
<table border="0" width="343">
<tr>
<td width="92">Campo 1</td>
<td width="241"><%=Request("Dato1")%></td>
</tr>
<tr>
<td width="92">Campo 2</td>
<td width="241"><%=Request("Dato2")%></td>
</tr>
<tr>
<td width="92">Campo 3</td>
<td width="241"><%=Request("Marchio")%></td>
</tr>
<tr>
<td width="92">Campo 4</td>
<td width="241"><%=Request("Categoria")%></td>
</tr>
</table>
</body>
</html>