Dear all,
I have datepicker and file upload with condition if datepicker value has interval more than 730 (2 years) then fileupload will visible else fileupload will hidden. I already have scratch code
that code works perfectly, but How to implement this code into chronoform? I confused to put onchange event for datepicker😟.
Thank you
I have datepicker and file upload with condition if datepicker value has interval more than 730 (2 years) then fileupload will visible else fileupload will hidden. I already have scratch code
<!doctype html>
<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();
document.getElementById("fileupload").style.visibility="hidden";
});
function myFunction(val) {
//alert("The input value has changed. The new value is: " + val)
var _myDate = new Date($('#datepicker').val() );
var date2 = new Date();
var timeDiff = Math.abs(date2.getTime() - _myDate.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
var elem = document.getElementById("interval");
elem.value = (diffDays);
if (diffDays > 730){
document.getElementById("fileupload").style.visibility="visible";
}else{
document.getElementById("fileupload").style.visibility="hidden";
}
}
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" onchange="myFunction(this.value)"></p>
<p><input type="hidden" id="interval"></p>
<p><input type="file" id="fileupload"></p>
</body>
</html>
that code works perfectly, but How to implement this code into chronoform? I confused to put onchange event for datepicker😟.
Thank you