se per te non è un disturbo vorrei porti un'altro problema ...

Questo è il codice.... un po' lunghetto a causa di javascript che ho usato per i controlli...
Siccome non sono pratico non so se li ho utilizzati in modo corretto e volevo fare in modo che in questo form di circa una ventina di voci quando clicco sul pulsante di invio i campi che non sono stati riempiti assumano automaticamente ilvalore "nd"
In parte ci sono riuscito ma mi succede questo... se i campi non riempiti ne sono 4 per esempio,prima di inviare il rm dovro' premere per 4 volte il pulsante in modo che compaia itutti i campi la stringa "nd".
Spero stato chiaro....
Nel codice alcuni campi sono obbligatori... altri no... e su questi non obbligatori vorrei che funzionasse come ho spiegato sopra!Spero in una risposta.... Grazie





<%@LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<% If not Session("BoleanAccess") = True then
Response.Redirect("FormLogin.asp")
end if %>
<html>
<head>
<title>Consip</title>
<script type="text/javascript" language="JavaScript1.2">

function verifica() {
var re = /^[A-z]{6}\d{2}[A-z]\d{2}[A-z]\d{3}[A-z]$/;
var re2 = /\d{11}/
if ((document.form.Rf_Nome.value == "") || (document.form.Rf_Nome.value == "undefined")) {
alert("Il campo nome del referente è obbligatorio.");
document.form.Rf_Nome.focus();
return false;
}
else if ((document.form.Rf_Cognome.value == "") || (document.form.Rf_Cognome.value == "undefined")) {
alert("Il campo cognome del referente è obbligatorio.");
document.form.Rf_Cognome.focus();
return false;
}
else if (document.form.Rf_DataNascita.value.substring(2,3) != "/" || document.form.Rf_DataNascita.value.substring(5,6) != "/" ||
isNaN(document.form.Rf_DataNascita.value.substring (0,2)) || isNaN(document.form.Rf_DataNascita.value.substring (3,5)) ||
isNaN(document.form.Rf_DataNascita.value.substring (6,10))) {
alert("Inserire la data di nascita in formato gg/mm/aaaa");
document.form.Rf_DataNascita.value = "";
document.form.Rf_DataNascita.focus();
return false;
}
else if (document.form.Rf_DataNascita.value.substring(0,2) > 31) {
alert("Impossibile utilizzare un valore superiore a 31 per i giorni");
document.form.Rf_DataNascita.select();
return false;
}
else if (document.form.Rf_DataNascita.value.substring(3,5) > 12) {
alert("Impossibile utilizzare un valore superiore a 12 per i mesi");
document.form.Rf_DataNascita.value = "";
document.form.Rf_DataNascita.focus();
return false;
}
else if (document.form.Rf_DataNascita.value.substring(6,10 ) < 1900) {
alert("Impossibile utilizzare un valore inferiore a 1900 per l'anno");
document.form.Rf_DataNascita.value = "";
document.form.Rf_DataNascita.focus();
return false;
}
else if ((document.form.Rf_LuogoNascita.value == "") || (document.form.Rf_LuogoNascita.value == "undefined")) {
alert("Il campo luogo di nascita del referente è obbligatorio.");
document.form.Rf_LuogoNascita.focus();
return false;
}
else if ((document.form.Rf_NumeroDocumento.value == "") || (document.form.Rf_NumeroDocumento.value == "undefined")) {
alert("Il campo numero documento del referente è obbligatorio.");
document.form.Rf_NumeroDocumento.focus();
return false;
}
else if (re.exec(document.form.Rf_CodiceFiscale.value) == null) {
alert("Inserire un codice fiscale corretto.");
document.form.Rf_CodiceFiscale.focus();
return false;
}
else if ((document.form.Rf_Incarico.value == "") || (document.form.Rf_Incarico.value == "undefined")) {
document.form.Rf_Incarico.value = "nd";
document.form.Rf_Email.focus();
return false;
}
else if ((document.form.Rf_Email.value == "") || (document.form.Rf_Email.value == "undefined")) {
document.form.Rf_Email.value = "nd";
document.form.Rf_FirmaDigitale.focus();
return false;
}
else if ((document.form.Rf_FirmaDigitale.value == "") || (document.form.Rf_FirmaDigitale.value == "undefined")) {
document.form.Rf_FirmaDigitale.value = "nd";
document.form.Az_Livello.focus();
return false;
}
if ((document.form.Az_Livello.value == "") || (document.form.Az_Livello.value == "undefined")) {
document.form.Az_Livello.value = "nd";
document.form.Az_DenominazioneUfficio.focus();
return false;
}
else if ((document.form.Az_DenominazioneUfficio.value == "") || (document.form.Az_DenominazioneUfficio.value == "undefined")) {
alert("Il campo 'Denominazione Ufficio' è obbligatorio.");
document.form.Az_DenominazioneUfficio.focus();
return false;
}
else if (re2.exec(document.form.Az_PartitaIva.value) == null) {
alert("La partita IVA è obbligatoria.");
document.form.Az_PartitaIva.focus();
return false;
}
else if ((document.form.Az_Indirizzo.value == "") || (document.form.Az_Indirizzo.value == "undefined")) {
alert("Inserire l'indirizzo dell'azienda.");
document.form.Az_Indirizzo.focus();
return false;
}
else if ((document.form.Az_Citta.value == "") || (document.form.Az_Citta.value == "undefined")) {
alert("Inserire la città.");
document.form.Az_Citta.focus();
return false;
}
else if ((document.form.Az_Cap.value == "") || (document.form.Az_Cap.value == "undefined")) {
alert("Inserire il CAP.");
document.form.Az_Cap.focus();
return false;
}
else if ((document.form.Az_Telefono.value == "") || (document.form.Az_Telefono.value == "undefined")) {
alert("Inserire il telefono dell'azienda.");
document.form.Az_Telefono.focus();
return false;
}
else if ((document.form.Az_Fax.value == "") || (document.form.Az_Fax.value == "undefined")) {
document.form.Az_Fax.value = "nd";
document.form.Az_Url.focus();
return false;
}
else if ((document.form.Az_Url.value == "") || (document.form.Az_Url.value == "undefined")) {
document.form.Az_Url.value = "nd";
document.form.Az_Email.focus();
return false;
}
else if ((document.form.Az_Email.value == "") || (document.form.Az_Email.value == "undefined")) {
document.form.Az_Email.value = "nd";
document.form.Az_Email.focus();
return false;
}
else {
document.form.action = "InserimentoAzienda.asp";
document.form.submit();
}
}

</script>
</head>

<body>

<%
dim connDB
dim rsDati
dim PartitaIva
PartitaIva = Request.Form("PartitaIva")
connDB.Open
Set rsDati = connDB.Execute("SELECT Az_PartitaIva FROM AnagraficaAzienda WHERE Az_PartitaIva = '" & PartitaIva & "'")
if not rsDati.EOF then
Session("PIvaAzienda") = PartitaIva
rsDati.Close
connDB.Close
%>


Azienda gia presente nel database..


Clicca per andare al form di inserimento ordini...</p>

<% else %>


<h2>Inserimento Anagrafica Azienda.</h2></p>
<form name="formAnag" method="post">
<table align="center">
<tr>
<td width="180">Titolo</td>
<td><select name="Rf_Titolo" tabindex="1">
<option selected>Sig.</option>
<option>Sig.ra</option>
<option>Sig.na</option>
<option>Dott.</option>
<option>Dott.ssa</option>
</select></td>
<td rowspan="12" width="80"></td>
<td width="180">Livello</td>
<td><input name="Az_Livello" type="text" tabindex="13"></td>
</tr>
<tr>
<td>Nome</td>
<td><input name="Rf_Nome" type="text" tabindex="2"></td>
<td>Denominazione ufficio</td>
<td><input name="Az_DenominazioneUfficio" type="text" tabindex="14"></td>
</tr>
<tr>
<td>Cognome</td>
<td><input name="Rf_Cognome" type="text" tabindex="3"></td>
<td>Partita IVA</td>
<td><input name="Az_PartitaIva" type="text" tabindex="15" size="11" maxlength="11" readonly="true" value="<% Response.Write (PartitaIva) %>"></td>
</tr>
<tr>
<td>Data di nascita (gg/mm/aaaa)</td>
<td><input name="Rf_DataNascita" type="text" tabindex="4" size="10" maxlength="10"></td>
<td>Provincia</td>
<td><select name="Az_Provincia" tabindex="16">
<option value="nd"> -- Provincia --
<option value="AG">Agrigento
<option value="AL">Alessandria
<option value="AN">Ancona

</select></td>
</tr>
<tr>
<td>Provincia di nascita</td>
<td><select name="Rf_ProvinciaNascita" tabindex="5">
<option value="nd"> -- Provincia --
<option value="AG">Agrigento
<option value="AL">Alessandria
<option value="AN">Ancona
<option value="AO">Aosta
</select></td>
<td>Indirizzo</td>
<td><input name="Az_Indirizzo" type="text" tabindex="17"></td>
</tr>
<tr>
<td>Luogo di nascita</td>
<td><input name="Rf_LuogoNascita" type="text" tabindex="6"></td>
<td>Città</td>
<td><input name="Az_Citta" type="text" tabindex="18"></td>
</tr>
<tr>
<td>Tipo documento</td>
<td><select name="Rf_TipoDocumento" tabindex="7">
<option selected>Carta di identità</option>
<option>Patente</option>
</select></td>
<td>CAP</td>
<td><input name="Az_Cap" type="text" tabindex="19" size="5" maxlength="5"></td>
</tr>
<tr>
<td>Numero documento</td>
<td><input name="Rf_NumeroDocumento" type="text" tabindex="8" size="15" maxlength="15"></td>
<td>Telefono</td>
<td><input name="Az_Telefono" type="text" tabindex="20"></td>
</tr>
<tr>
<td>Codice fiscale</td>
<td><input name="Rf_CodiceFiscale" type="text" tabindex="9" size="16" maxlength="16"></td>
<td>Fax</td>
<td><input name="Az_Fax" type="text" tabindex="21"></td>
</tr>
<tr>
<td>Incarico</td>
<td><input name="Rf_Incarico" type="text" tabindex="10"></td>
<td>Url</td>
<td><input name="Az_Url" type="text" tabindex="22"></td>
</tr>
<tr>
<td>Email</td>
<td><input name="Rf_Email" type="text" tabindex="11"></td>
<td>Email</td>
<td><input name="Az_Email" type="text" tabindex="23"></td>
</tr>
<tr>
<td>Firma digitale</td>
<td><input name="Rf_FirmaDigitale" type="text" tabindex="12"></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="5" align="center"><input type="button" name="Submit" value="Invia" onClick="verifica()"></td>
</tr>
</table>

</form>

<%
rsDati.Close
connDB.Close
end if %>

</body>
</html>