errorPlacement

Discussion in 'JavaScript' started by Garret, Apr 19, 2010.

  1. #1
    Hi guys. I'm trying to make a contact form with the Jquery validation plugin.
    I was wondering how can I specify the error message ( for example the name error ) to insert after a label.

    I have this code:
    
    
    $(document).ready(function(){
    	
    $("#form").validate({
        
     rules: {
        
    name: "required",
    email: {
          	required: true,
          	email: true 
    		},	
    		
    subject: "required",
    message: "required"
    },
    
     
    messages: {
    
    name: "write your name!",
    email: {
    		required: "write your email address!",
          	email: "Invalid email address. Try again!", 
    		},
    	
    subject: "write a subject!",
    message: "write your message!",
    },
    
    
    errorPlacement: function(error, element) {
         error.insertAfter("#name_label")
        
    }
    })
    });
    
    
    Code (markup):
    I can make the error's go to the place i want, after the label I name, but I wanted to specify and put the each error in the respective label. Does anyone can tell me how can I do this please?

    ahh, and other question. Can i make, after having all fields validated and the mail sent, a image to appear on a div, by changing one image for another?

    Thanks
     
    Garret, Apr 19, 2010 IP