I have a function that I need to validate what the user typed, if it is true
enable datepicker
. But the way I did it is falling into the method POST
of asp.net
mvc
.
Is there a way to create a textbox
dynamically with jQuery
?
My code:
View:
<script>
$(document).ready(function () {
var senha = $('txtSenha').val();
$("#lblSenha").hide();
$('#txtNovaDtVenc').click(function () { <-- Aqui é o Datepicker
$("#lblSenha").toggle();
$('#btnOK').click(function () {
if (senha == "administrador") {
$("#txtNovaDtVenc").datepicker(
"option", "disabled", false);
}
});
});
});
</script>
<div id="lblSenha" style="width:300px">
<table>
<tr>
<td>
Senha:
</td>
<td>
@Html.TextBox("txtSenha", "", new { @class = "form-control form-control-custom", style="width:100px" })
</td>
<td>
<input type="submit" id="btnOk" class="" value="Ok" onclick=""/>
</td>
</tr>
</table>
</div>