Declining Character Textbox
@Html.TextAreaFor(model => model.agreement.purpose, new { maxlength = "500", id = "purpose", @class = "form-control", @rows = 5 })
<div style="font-size:11px; color:##999; font-weight:normal;"><span id="PurposeCounter">500</span> Characters remaining</div>
<script language="javascript">
function updatePurpose() {
var maxLength = 500;
summary = document.getElementById("purpose");
if (summary.value.length > maxLength) {
summary.value = summary.value.substring(0, maxLength);
}
else {
$("#PurposeCounter").html(maxLength - $("#purpose").html().length);
}
};
$("#purpose").keyup(function () {
updatePurpose();
});
updatePurpose();
</script>
<div style="font-size:11px; color:##999; font-weight:normal;"><span id="PurposeCounter">500</span> Characters remaining</div>
<script language="javascript">
function updatePurpose() {
var maxLength = 500;
summary = document.getElementById("purpose");
if (summary.value.length > maxLength) {
summary.value = summary.value.substring(0, maxLength);
}
else {
$("#PurposeCounter").html(maxLength - $("#purpose").html().length);
}
};
$("#purpose").keyup(function () {
updatePurpose();
});
updatePurpose();
</script>
Comments