Javascript :
Below is the code to validate fromdate and todate using javascript.
function validateDate() {
var fromdate, todate, date1, date2;
var chkFrom = document.getElementById('date');
var chkTo = document.getElementById('date2');
fromdate = chkFrom.value;
todate = chkTo.value;
date1 = new Date(fromdate);
date2 = new Date(todate);
if (date2 <= date1) {
alert("To date Should be greater than From date");
return false;
}
return true
}
</script>
Web Page:
calling the above javascript function on button click
<div>
<button type="button" id="btnsubmit" class="btn" onclick="return validateDate();"> Submit</button>
</div>
Below is the code to validate fromdate and todate using javascript.
function validateDate() {
var fromdate, todate, date1, date2;
var chkFrom = document.getElementById('date');
var chkTo = document.getElementById('date2');
fromdate = chkFrom.value;
todate = chkTo.value;
date1 = new Date(fromdate);
date2 = new Date(todate);
if (date2 <= date1) {
alert("To date Should be greater than From date");
return false;
}
return true
}
</script>
Web Page:
calling the above javascript function on button click
<div>
<button type="button" id="btnsubmit" class="btn" onclick="return validateDate();"> Submit</button>
</div>
No comments:
Post a Comment