scriptwelt.org das JavaScript Archiv

Navigation

Navigation Themenbereiche
Kontakt

eine Mail an ScriptWelt.org

Kontaktformular

Impressum
impressum

Formulare JavaScript / auto Datum im Formfeld

Das JavaScript erzeugt das aktuelle Datum in einem Formfeld.
Autor: Jean P. May

in <head> einfügen
<script type="text/javascript">
// Created by: Jean P. May, Anzeige geändert www.scritpwelt.org
function autoDate () {
var tDay = new Date();
var tMonth = tDay.getMonth()+1;
var tDate = tDay.getDate();
if ( tMonth < 10) tMonth = "0"+tMonth;
if ( tDate < 10) tDate = "0"+tDate;
document.getElementById("tDate").value = tDate+"/"+tMonth+"/"+tDay.getFullYear();
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}

addLoadEvent(function() {
autoDate();
});

</script>

in <body> einfügen

<input id="tDate" readonly="readonly">