<textarea id="text" class="e-textarea"></textarea> |
[html]
<form id="myform" name="messageForm">
<div class="control">
<textarea id="textarea" class="e-textarea" name="text"></textarea>
</div>
<div class="control">
<input type="submit" value="Submit" id="submit" />
</div>
</form>
[script]
$("[name='messageForm']").validate({
rules: {
text: {
required: true,
minlength: 8
}
},
messages: {
text: {
required: "Enter the value"
}
}
});
$.validator.setDefaults({
//to validate all fields(hidden also)
ignore: [],
//if we don’t set custom class, default “error” class will be added
errorClass: 'e-validation-error',
//it specifies the error message display position
errorPlacement: function (error, element) {
$(error).insertAfter(element.closest(".e-textarea"));
}
}); |