1

On my page, I'm using textbox with calendar extender to get the date value. I've added onchange="ValidateStartDate();" to the textbox.

 <asp:TextBox ID="TextBoxStartDate" runat="server"  ForeColor="Red"    
     onchange="ValidateRsmStartDate();"> 
     </asp:TextBox>               

<asp:CalendarExtender ID="CalendarExtenderStartDate" 
  TargetControlID="TextBoxStartDate"
  BehaviorID="ceStartDate"  
  PopupButtonID="CalendarExtenderStartDatePopup"                                                                     
  Format="MM/dd/yyyy" runat="server">
  </asp:CalendarExtender>

<img class="Spacer" id="CalendarExtenderStartDatePopup" src="Images/Calendar.png"                                                                                
   alt="Start Date" />

My javascript function:

function ValidateStartDate() {
   var txtDate = document.getElementById('<%=TextBoxStartDate.ClientID  %>');
   alert(txtDate.innerHTML);
}

But on alert(), I get no value at all.

3 Answers 3

3

Textbox does not have innerHTML, you need to use value

Change

alert(txtDate.innerHTML);

To

alert(txtDate.value);
Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome, No worries some times we forget simple things.
1

You can easily integrate it from jquery. Just write below line in your function.

alert($("#<%=TextBoxStartDate.ClientID  %>").val());

Or

Replace your code from alert(txtDate.innerHTML); to alert(txtDate.value);

Comments

0

Using jQuery:

$(function(){
    $('<%=TextBoxStartDate.ClientID%>').on("change", function(){
     alert($(this).val());
    });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.