1
I have a Function that I need to validate what the user has typed, if applicable true
enables the datepicker
. But the way I did, you’re falling for the method POST
of asp.net
mvc
.
There is 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>
Dude because when I click on my ok button it falls in the post method of Asp.net mvc ? there is no way I can do this only in jQuery ?
– AndreeH
This is because your button is type Submit, the default behavior of this type of button is just to send the form data (POST or GET). If you want to change this behavior you change the type of button to button for example.
– Eduardo Silva
Probably because it is a button of type "Submit". Perhaps it is better to switch to type "button".
– Daniel Omine
@Danielomine Cara, it worked to change the button, but I have another one and there’s no id ? And also, the time I put in case the right password, does not enable datepicker.
– AndreeH
There are already another 500.. try to solve and if you have doubt opens new question about datepicker..
– Daniel Omine