Hello. I'm learning how to use the jQuery validation plug-in.
What'd I'd like to do is only show an ICON (css bkg) if the field is valid or in error.
Right now the plugin requires me to add text, but I don't want any...
Ideas?
Code Below:
/* Sign In Form Validation */
$(document).ready(function() {
// validate signup form on keyup and submit
var validator = $("#user_new").validate({
rules: {
'user[fname]': {
required: true,
minlength: 1
}
},
messages: {
'user[fname]': "Enter your user_fname"
},
// the errorPlacement has to take the table layout into account
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.appendTo( element.parent().next() );
},
// set this class to error-labels to indicate valid fields
success: function(label) {
// set as text for IE
label.html(" ").addClass("checked");
}
});
});
I tried blanking out the messages arry like:
'user[fname]': ""
And if I don't include it, it shows the default error message.
Thanks for any tips.