I think you should know that for datapicker
to work you should add the libs of it ...
In this case, in addition to JQuery
I am using the JQuery-UI
library:
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
HTMLcode:
<inputtype="text" id="inicio" name="inicio">
<input type="text" id="final" name="final">
<input type="button" id="testar" name="testar" value="testar">
JS Code:
$(document).ready(function () {
$('#inicio').datepicker({ dateFormat: 'dd/mm/yy' }).val();
$('#final').datepicker({ dateFormat: 'dd/mm/yy' }).val();
});
$("#testar").click(function() {
var inicio = $('#inicio').val();
var final = $('#final').val();
if (inicio > final) {
alert('inicio é maior que final');
}else{
alert('final é maior que inicio');
}
});
Here in JsFiddle an example of datapicker
working the way you need it ...