Need some help placing form errors using Jörn's validation plugin
I'm trying to edit the plug-in so that the form errors are always inserted into a div.class=error-box. 9 times out of 10 the div.error-box will be right after the input but sometimes it will need to be moved. So the idea is wherever div.error-box is, thats where the validation plug-in would generate the error for the individual input.
I know Jörn's plug-in has a feature to specify the error placement, I'm just having trouble figuring out how to tweak it work with what I want to do.
Here is one of the examples of errorPlacement
// errorPlacement
errorPlacement: function(error, element) {
if ( element.is(":radio") )
error.appendTo( element.parent().next().next() );
else if ( element.is(":checkbox") )
error.appendTo ( element.next() );
else
error.append( element.next().next() );
},
I had come up with
// errorPlacement
errorPlacement: function(error, element) {
error.each.prepend('<div class=error-box"></div>');
},
but this seems to be incorrect.
开发者_JS百科Any help would be greatly appreciated!
I found what I was looking for here - http://forum.jquery.com/topic/help-with-validation-error-message-placement
精彩评论