Is there a way to access the content of an ASP.NET MVC textbox using JavaScript?
I have two textboxes displayed below and I am attempting to extract the data entered via a date-picker using the following JavaScript code. However, my current approach is returning null values.
Code:
@Html.Label("Start", "Start Date:")
@Html.TextBox("Start", string.Empty, new {@id = "Start", @class = "datepicker"})
@Html.Label("endd", "End Date:")
@Html.TextBox("endd", string.Empty, new {@id = "End", @class = "datepicker"})
<input type="submit" value="Apply" id ="DateSelected" />
<script type="text/javascript">
$('.datepicker').datepicker();
$("#DateSelected").onclick(function () {
var value1 = document.getElementById('<%=Start.ClientID%>').value;
var value2 = document.getElementById('<%=End.ClientID%>').value;
</script>