So I have a particular function that needs to repeated again and again. So I thought I would make just one function that can be re-used.
function validate_form(field,validate) {
field.focus(function(){
$(validate).css('margin-left','206px');
$(validate).fadeIn();
$(validate).animate({
'marginLeft': '286px'
}, 'fast');
name = $(field).val();
alert(name);
});
}
to call the function I would use something like
validation_form('#contact_name','#contact_name_validate');
So the idea here is to pass through the particular selectors required into the function, but I just cant seem to get it working. Is there some special way to pass through selectors when they are used as variables in a function?