anche tu hai ragione ma a me nn mi entra x nulla dentro alla funzione aspe ora ti rimetto tutti e due xkè gli ho fatto qualche modifica....
html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN " "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Test</title>
<link rel="Stylesheet" type="text/css"
href="test.css" />
<script type="text/javascript" src="funzioni.js">
</script>
</head>
<body>
<fieldset>
<legend>Inserimento dati</legend>
<fieldset>
<legend>Data di nascita:</legend>
<input type="text" name="data" id="date">
</fieldset>
<fieldset>
<legend>Codice Fiscale:</legend>
<input type="text" name="codfis" id="codfis">
</fieldset>
<input type="submit" id="invia" value="INVIA" onclick="control(document.getElementById('data').v alue)" />
</fieldset>
</body>
</html>
js:
function control(data)
{
int a;
// ************************************************** **************************************
// Verifica che data(stringa), se valorizzata, sia una data valida.
function ChkDataString(data)
{
if (IsValorizzatoString(data) == 0)
{
return 1
a = 1;
}
var sNewDate;
var nRetVal;
var gg=0;mm=0;aa=0;
var nPos=0;nPos1=0;
var d=new Date();
if (data.length != 10)
{
return 0
a = 0;
}
//alert("ok lunghezza')
if (data.charAt(2)!='/') return 0;
if (data.charAt(5)!='/') return 0;
ggx=data.substring(0,2);
mmx=data.substring(3,5);
aaaax=data.substring(6,10);
if (IsNumericString(ggx)==0 || IsNumericString(mmx)==0 || IsNumericString(aaaax)==0)
{
return 0;
int a = 0;
}
//alert("ok formato')
nPos=data.indexOf('/',0);
if (nPos>0)
{
mm=0;
aa=0;
gg=parseInt(TogliZero(data.substring(0,nPos)));
mm=parseInt(TogliZero(data.substring(nPos+1)));
nPos1=data.indexOf('/',nPos+1);
if (nPos1>0)
{
aa=parseInt(TogliZero(data.substring(nPos1+1)))
}
}
else
{
gg=parseInt(TogliZero(data.substring(0,2)));
mm=parseInt(TogliZero(data.substring(4,2)));
aa=parseInt(TogliZero(data.substring(4)));
}
if (isNaN(gg))
gg=0
if (isNaN(mm))
mm=0
if (isNaN(aa))
aa=0
if (aa==0)
aa=d.getFullYear();
if (mm==0)
mm=d.getMonth()+1;
nRetVal=idata(gg,mm,aa);
if (nRetVal==0)
{
return 0
a = 0;
}
if (gg<10) gg = "0" + gg;
if (mm<10) mm = "0" + mm;
if (aa<10) aa = "0" + aa;
if (aa<100) aa = "0" + aa;
if (aa<1000) aa = "0" + aa;
sNewDate=gg + "/" + mm + "/" + aa;
//oDate.value=sNewDate;
data=sNewDate;
return 1;
a = 1;
}
// ************************************************** **************************************
function isDate(gg,mm,aa)
{
var nRetVal=1;
if (aa<80)
aa=aa+2000;
else
if (aa<100)
aa=aa+1900;
var DD=parseInt(mm) + '/'+parseInt(gg)+'/'+parseInt(aa);
var d= new Date(DD);
gg1=d.getDate();
mm1=d.getMonth()+1;
aa1=d.getFullYear();
var DD1=mm1 + '/'+gg1+'/'+aa1;
var d1=new Date(DD1);
if (DD1!=DD)
nRetVal=0;
return nRetVal;
}
// ************************************************** **************************************
function TogliZero(sText)
{
nn=sText.indexOf('0',0);
if (nn==0)
{
sTT=sText.substring(1);
}
else
{
sTT=sText;
}
return sTT;
}
//************************************************** ********************************************
function check()
{
a = 0;
if(a = 1)
{
window.open('ricevo.html' ,'width=300', 'height=300' );
}
else
{
alert("I dati inseriti non sono corretti!");
}
}
}
il codice è proprio trp lungo, non so ora se il problema è ke nn può esistere + funzioni dentro ad unaltra (ma non credo...) oppure nn lo so help me!!

Rispondi quotando