Hi Team,
Unable to get correct format of the date in JavaScript. Button click event.
Date format is showing like (|0|052015-4-1-0-0-0-0||) but I need (MM/dd/yyyy)
Please let me know how to achieve this
code:
<ig:WebDatePicker ID="StartDate" runat="server" BorderColor="Gray"
BorderWidth="1px" Width="100px" CssClass="tableElement" BorderStyle="Inset"
Height="15px" Editable="False" NullDateLabel=""
Buttons-CustomButton-ImageUrl="../images/cal.gif"
DataMode="EditModeText" EditMode="CalendarOnly"
DisplayModeFormat="MM/dd/yyyy" style="position:absolute;" EnableAjaxViewState="False" Culture="en-AU">
<CalendarAnimation FadeOpenDuration="0" SlideOpenDuration="0" />
<CalendarAnimation FadeCloseDuration="100" />
</ig:WebDatePicker>
<asp:Button ID="btnCalculate" runat="server" CssClass="ButtonText" Text="Calculate" EnableViewState="false"/>
Thanks
Ranganathan Palanisamy
Thanks It's worked .. I made one more change ClientIDMode=static
Hello,
In order to get the date using JavaScript, you could use the following approach using simple button.
Try this and bear in mind that JavaScript months are 0-indexed, whilst days are 1-indexed.
<script> function AlertDateFormat() { var datePiceker = $find("WebDatePicker1"); var date = datePiceker._date; alert((date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear()); } </script></head><body> <form id="form1" runat="server"> <div> <ig:WebScriptManager ID="WebScriptManager1" runat="server"></ig:WebScriptManager> <ig:WebDatePicker ID="WebDatePicker1" runat="server" ></ig:WebDatePicker> <button onclick="AlertDateFormat()"> </button> </div> </form></body>
Please let me know how this approach works for you.