1
I have a Function that needs to take the value of the textbox to perform a validation and if this validation is true enable datepicker. But it’s not taking value from the textbox. By giving an Alert in the textbox, it is showing "Undefined". How can I solve ?
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>
<table id="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>
How are you giving the alert?
– Joao Paulo
Mark the question as answered...
– ShutUpMagda