Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
how to assign todat date in date filter


What I have tried:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
var today="ffffffff";
alert(today);
$("#a").val(today);
});
</script>
</head>
<body>

Name: <input id="a" type="date" name="user">



<button>Set the value of the input field</button>

</body>
</html>
Posted
Updated 26-Aug-16 3:21am

1 solution

try this

JavaScript
$(document).ready(function () {
           var today = new Date();
           var month = (today.getMonth() + 1).toString();
           month = month.length == 1 ? "0" + month : month;
           var day = today.getDate().toString();
           day = day.length == 1 ? "0" + day : day;
           var year = today.getFullYear();
           var format = year + '-' + month + '-' + day
           $("#a").val(format);
       });
 
Share this answer
 
Comments
xszaboj 26-Aug-16 9:25am    
http://codepen.io/xszaboj/pen/qNZWdj working example of question code
Nethaji chennai 26-Aug-16 9:25am    
this method assign value to datefilter;
but date is change in first day of month
Karthik_Mahalingam 26-Aug-16 9:27am    
means?
Nethaji chennai 26-Aug-16 9:30am    
format =dd-mm-yy;
value =01-08-2016
Karthik_Mahalingam 26-Aug-16 9:37am    
http://codepen.io/xszaboj/pen/qNZWdj

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900