Display weekday in textbox or label using date from textbox

Posted by Niels Schultz on Stack Overflow See other posts from Stack Overflow or by Niels Schultz
Published on 2010-05-20T12:08:05Z Indexed on 2010/05/20 12:10 UTC
Read the original article Hit count: 692

I have a textbox with calendar extender and a label

           <label for="<%= tbxFrom.ClientID %>">
                From</label>
                <asp:Label ID="lblWeekDayFrom" runat="server"></asp:Label>
            <asp:TextBox ID="tbxFrom" runat="server" CssClass="Calendar"></asp:TextBox>
            <cc1:CalendarExtender ID="extTbxFrom" runat="server" TargetControlID="tbxStartTag">
            </cc1:CalendarExtender>

and now I would like to show the weekday of the currently selected date, either using a formatting inside the textbox like

Th 05/20/2010

or showing the weekday as string using the label on the left side of the texbox (lblWeekDayFrom). There is a calendarExtender to select the date, but I would also like to be able to have the users enter the date manually.

I tried to use JQuery to capture changes, but the label is not showing anything, and it triggers the RequiredFieldValidator on every initial page load.

 $(document).ready(function() 
    {
       $('#<%= tbxFrom.ClientID %>').change(updateDate($('#<%= tbxFrom.ClientID %>').val()))    
    }
  );
 function updateDate(date)  
 {  
    $('#<%= lblWeekDayFrom.ClientID %>').val(date);   
 }

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about textbox