javascript by example
javascript by example
javascript by example
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Capitolo 1<br />
}<br />
}<br />
default:<br />
day = matchArray[5];<br />
month = matchArray[3];<br />
year = matchArray[1];<br />
break;<br />
return isRealDate(obj,'gma');<br />
Linguaggio<br />
if (day < 1 || day > 31) return false; //il giorno deve essere da 1 a 31<br />
if (month < 1 || month > 12) return false; //il mese deve essere<br />
//questi mesi hanno 30 giorni:<br />
da 1 a 12<br />
if ((month==4 || month==6 || month==9 || month==11) && day==31)<br />
if (month == 2) { //febbraio<br />
}<br />
//verifica se l'anno è bisestile<br />
return false;<br />
var bisestile = (year % 4 == 0 && (year % 100 != 0 || year % 400<br />
if (day > 29 || (day==29 && !bisestile)) return false;<br />
return true; //la data è valida<br />
//Esempio:<br />
var date = new Date(2007,5,1);<br />
var sdate = "01/06/2007";<br />
var nodate = "non è una data";<br />
document.write (isRealDate(date,'gma')); // true<br />
document.write ('');<br />
document.write (isRealDate(sdate,'gma')); // true<br />
document.write ('');<br />
document.write (isRealDate(nodate,'gma')); // false<br />
== 0));<br />
14 La variabile è definita?<br />
A volte può essere necessario sapere se una determinata varia-<br />
I libri di ioPROGRAMMO/Javascript <strong>by</strong> Example 17<br />
JAVASCRIPT<br />
BY EXAMPLE