I’ve implemented the jQuery validation plugin from bassistance.de and use it by manually defining rules below each form I’d like to have validated.
I would like to modify the fields (eg. give them a border-color) that I defined as required after the script initialisation is done, but I can’t seem to find a generic ‘loaded’ callback, event or extending possibilities.
Is there a way to perform a script each time that $('#form').validate(..) is finished initializing?
The way I’m solving it right now is as follows:
$(document).ready(function() {
$('#myForm').validate({
rules: {
txtCode: { required: true, maxlength: 12 },
txtName: { required: true, maxlength: 50 },
}
});
$('#myForm').highlightRequiredFields();
});
.. where highlightRequiredFields() is a simple jQuery plugin I wrote to modify the required textboxes. I’m just not so keen on duplicating that line to all my form validations.
Thanks everyone. Zachary’s respond made me realise it’s much easier than I thought.
I ended up adding this overload: