I have a textbox(it gets integer value) on my page and i set "0" to textboxes with this script at startup.
<script>
$(document).ready(function () {
$('.myclass').each(function () {
this.value = this.value || "0";
});
});
</script>
Also my textbox looks like:
@Html.TextBoxFor(model => model.Answers[i].Answer, new { @style = "width:45px; margin-left:10px; margin-bottom:10px; text-align:center;", @class="myclass" })
@Html.ValidationMessageFor(model => model.Answers[i].Answer)
How can i set null value after validation after postback? Because script set 0 value to textbox after every postback?
Thanks for help.