Display the Day of given Date using Jquery.
You entered Some date it will display the day of that date.
Example: 02-Feb-2016.
Your Entered date is Tuesday.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function(){
$('#datepicker_1').datepicker({
dateFormat: 'mm/dd/yy',
showAnim: 'show',
onSelect: function(dateText){
var seldate = $(this).datepicker('getDate');
seldate = seldate.toDateString();
seldate = seldate.split(' ');
var weekday=new Array();
weekday['Mon']="Monday";
weekday['Tue']="Tuesday";
weekday['Wed']="Wednesday";
weekday['Thu']="Thursday";
weekday['Fri']="Friday";
weekday['Sat']="Saturday";
weekday['Sun']="Sunday";
var dayOfWeek = weekday[seldate[0]];
$('#dayOfWeekSpan').html("You selcted "+dayOfWeek+"");
},
onClose: closeDatePicker_datepicker_1
});
});
function closeDatePicker_datepicker_1() {
var tElm = $('#datepicker_1');
if (typeof datepicker_1_Spry != null && typeof datepicker_1_Spry != "undefined" && test_Spry.validate) {
datepicker_1_Spry.validate();
}
tElm.blur();
}
</script>
</head>
<body>
<h2>Selected Date to show Day</h2>
<input id="datepicker_1" name="test" type="text" />
<span id="dayOfWeekSpan"></span>
</body>
</html>
Comments
Post a Comment