Reputation: 201
I'm using datepicker plugin for my 2 date label and I'm trying to add another function that is date validation.
Here's my code for datepicker plugin
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<script>
$(function() {
$( "#datepicker2" ).datepicker();
});
</script>
</head>
<body>
<p>Date From: <input type="text" id="datepicker"></p>
<p>Date To: <input type="text" id="datepicker2"></p>
</body>
</html>
Here's the javascript for date validation
<script>
$("#from").change(function(){
$("#to").attr("min",$(this).val());
});
$("#to").change(function(){
$("#from").attr("max",$(this).val());
});
</script>
Upvotes: 0
Views: 39
Reputation: 2258
run the validation on window.load()
https://jqueryui.com/datepicker/#date-range
is the perfect example
Upvotes: 1