
Untitled
By: a guest on
Jun 22nd, 2012 | syntax:
None | size: 1.16 KB | hits: 16 | expires: Never
jquery validator errorPlacement offset problem
$(document).ready(function() {
var tabs = $("#tabs").tabs();
var validator = $("#myForm").validate({
errorElement: "div",
wrapper: "div", // a wrapper around the error message
errorPlacement: function(error, element) {
if (element.parent().hasClass('group')){
element = element.parent();
}
offset = element.position();
error.insertBefore(element)
error.addClass('message'); // add a class to the wrapper
error.css('position', 'absolute');
error.css('left', offset.left + element.outerWidth());
error.css('top', offset.top);
}
});
}
$(document).ready(function() {
var validator = $("#myForm").validate({
... // your settings
ignore : ['#tabs .inactive input'] // tells the validator to only validate elements on your current tab
});
}
$(".forward").click(function() {
if (validator.form()) { // triggers validation of the currently visible form inputs
// step forward to the next tab
}
});
});