I'm having trouble trying to validate a user bypassing the maxlength value in a textarea field but it seems none of my validations work. I'm trying to validate is a user can change the maxlength above our initial limit or if the maxlength is removed from the element.
It's kinda easy to do that but some users seem to be doing it.
Here's my code:
<form class="forms" action="/checkout" name="ordersubmit" id="shipping" method="post" novalidate="">
<div class="col-xs-12 col-sm-offset-1 col-sm-11 noPadding">
<label class="InstructionsBlock" for="Instructions">
Instructions
</label>
<textarea id="Instructions" name="Instructions" maxlength="62" rows="6" cols="50">
</textarea>
</div>
</form>
var instructions = $("#Instructions");
$("form").submit() {
if (instructions.val(instructions.attr("maxlength")) > 70 || instructions.length) {
alert("Please limit your instruction to a maximum of 70 characters");
}
}
When the form is submitted it doesn't validate and the solution might be easier than I thought but I can't seem to make this work.