This is the script i use for the date:
<script type="text/javascript">
var datefield=document.createElement("input")
datefield.setAttribute("type", "date")
if (datefield.type!="date"){ //if browser doesn't support input type="date", load files for jQuery UI Date Picker
document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n')
document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n')
document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n')
}
</script>
Alert is not working when the requirement is not fullfilled. Below is my code:
function validateForm() {
var x = document.forms["myForm"]["from"].value;
if (x == null || x == "") {
alert("please choose the date");
return false;
}
var y = document.forms["myForm"]["to"].value;
if (y == null || y == "") {
alert("please choose the date");
return false;
}
var date1 = new Date("x");
var date2 = new Date("y");
var diffDays = (date1 - date2);
var totalSeconds = diffDays / 1000;
var days = Math.floor(totalSeconds / 86400);
if(days < 7 )
{
alert("please be more than 7 days");
return false;
}
I have problem in getting the range between the dates. Any help will be appreciated.