I have a function that needs to get the value of the textbox to perform a validation and if this validation is true enable the datepicker. But when not taking value from the textbox. When giving an alert in the textbox, it is showing "Undefined". How can I resolve?
Script:
$(document).ready(function () {
$("#txtNovaDtVenc").datepicker("option", "disabled", true, { changeMonth: true, changeYear: true }).attr('readonly', 'readonly');
$("#EscolhaData").hide();
$('.a').click(function () {
$("#EscolhaData").toggle();
$('button').click(function () {
var senha;
senha = $("txtSenha").val();
alert(senha);
if (senha == "administrador") {
$("#txtNovaDtVenc").datepicker({ changeMonth: true, changeYear: true }).attr('readonly', 'readonly');
$("#LinhaSenha").hide();
}
});
});
});
HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><tableid="EscolhaData">
<tr>
<td>
Nova dt. de vencimento :
</td>
<td>
@Html.TextBox("txtNovaDtVenc", "", new { @class = "form-control form-control-custom", style="width:100px" })
</td>
</tr>
<tr id="LinhaSenha">
<td>
Senha:
</td>
<td>
@Html.TextBox("txtSenha", "", new { @class = "form-control form-control-custom", style="width:100px" })
</td>
<td>
<button type="button" value="Ok" style="width:30px; height:30px;"></button>
</td>
</tr>
</table>