Skip to content

Instantly share code, notes, and snippets.

@scan
Created August 14, 2012 16:52
Show Gist options
  • Save scan/3350816 to your computer and use it in GitHub Desktop.
Save scan/3350816 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function check() {
var day = parseInt(document.getElementById("iDay").value);
var month = parseInt(document.getElementById("iMonth").value) - 1;
var year = parseInt(document.getElementById("iYear").value);
console.log([day,month,year]);
var date = new Date(year, month, day);
console.log(date);
if (day !== date.getDate() || month !== date.getMonth() || year !== (1900 + date.getYear())) {
window.alert("die eingabe ist inkorrekt");
// return false;
} else {
// return true;
window.alert("alles super");
}
}
</script>
</head>
<body>
<form onsubmit="check()" action="#">
<input type="text" id="iDay" />
<input type="text" id="iMonth" />
<input type="text" id="iYear" />
<input type="submit" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment