Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<script type="text/javascript">
/*<![CDATA[*/
function Days(frm,f,t,ip){
var f=frm[f].value.split(/\D/),t=frm[t].value.split(/\D/),days,z0;
if (f.length==3&&t.length==3&&f.join('')<t.join('')){
days=new Date(f[0],f[1],1,-1).getDate()-f[2];
t[0]-f[0]
for (z0=f[1]*1+1;z0<t[1]*1+(t[0]-f[0])*12;z0++){
days+=new Date(f[0],z0,1,-1).getDate();
}
frm[ip].value=days+t[2]*1;
}
}
/*]]>*/
</script></head>
<body>
<form>
<input name="from" value="2012-02-27" />
<input name="to" value="2012-05-02" />
<input type="button" name="" value="test" onmouseup="Days(this.form,'from','to','days');" />
<input name="days" />
</form>
</body>
</html>
Bookmarks