I have the folliwng code working, however I feel that there is a cleaner way of writing it.
<script type="text/javascript">
$(document).ready(function () {
$("#formRequest").validate({
highlight: function (element, errorClass) {
$(element).addClass("rfvTB");
},
unhighlight: function (element, errorClass) {
$(element).removeClass("rfvTB");
}
});
$.validator.messages.required = ' *';
});
</script>
the validation message seems like it belongs within the validate function. Is there a way of writing this cleaner?
There isn’t a wonderful way to do that without a bunch of statements inside your validate object:
You can specify the
messagesoption in validate, and then for each required element, add arequired: '*', like this:If you have a lot of elements, this is pretty tedious and I would prefer your method.