Skip to content

Instantly share code, notes, and snippets.

@abdelouahabb
Created September 16, 2014 23:05
Show Gist options
  • Save abdelouahabb/9d374148be3deadaa979 to your computer and use it in GitHub Desktop.
Save abdelouahabb/9d374148be3deadaa979 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>
ba3333
</title>
<meta charset="utf-8">
<style>
input {
display: block
}
</style>
<script>
function datm(d1, d2) {
var now = new Date;
document.getElementById(d2).min = document.getElementById(d1).min = now.toISOString().slice(0, 10)
}
function datc(d1, d2) {
var dat1 = new Date(document.getElementById(d1).value)
var dat2 = new Date(document.getElementById(d2).value)
if (dat1 - dat2 > 0) {
alert("le départ doit être avant l'arrivé, non -_- ")
return false
}
}
</script>
</head>
<body onload="datm('dat1', 'dat2')">
<form onsubmit="datc('dat1', 'dat2')">
<label for="dat1">Date de départ</label>
<input type="date" id="dat1" required/>
<label for="dat2">Date d'arrivée</label>
<input type="date" id="dat2" required/>
<hr>
<input type="submit" value="Vérifier">
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment