/* ---------------------------------------------
 Contact form
 --------------------------------------------- */
$(document).ready(function(){
    $("#submit_btn").click(function(){
        
        //get input field values
        var user_name = $('input[name=name]').val();
        var user_email = $('input[name=email]').val();
        var user_message = $('textarea[name=message]').val();
        
        //simple validation at client's end
        //we simply change border color to red if empty field using .css()
        var proceed = true;
        if (user_name == "") {
            $('input[name=name]').css('border-color', '#e41919');
            proceed = false;
        }
        if (user_email == "") {
            $('input[name=email]').css('border-color', '#e41919');
            proceed = false;
        }
        
        if (user_message == "") {
            $('textarea[name=message]').css('border-color', '#e41919');
            proceed = false;
        }
        
        //everything looks good! proceed...
        if (proceed) {
            //data to be sent to server
            post_data = {
                'userName': user_name,
                'userEmail': user_email,
                'userMessage': user_message
            };
            
            //Ajax post data to server
            $.post('contact_me.php', post_data, function(response){
            
                //load json data from server and output message     
                if (response.type == 'error') {
                    output = '<div class="error">' + response.text + '</div>';
                }
                else {
                
                    output = '<div class="success">' + response.text + '</div>';
                    
                    //reset values in all input fields
                    $('#contact_form input').val('');
                    $('#contact_form textarea').val('');
                }
                
                $("#result").hide().html(output).slideDown();
            }, 'json');
            
        }
        
        return false;
    });
    
    //reset previously set border colors and hide all message on .keyup()
    $("#contact_form input, #contact_form textarea").keyup(function(){
        $("#contact_form input, #contact_form textarea").css('border-color', '');
        $("#result").slideUp();
    });
    
});

@@ -1845,16 +1845,36 @@
 fields%0D%0A
+                  %0D%0A
         
@@ -1879,33 +1879,34 @@
               $(
-'
+ %22
 #contact_form in
@@ -1906,15 +1906,26 @@
 form
- 
+%22 ).find( %22
 input
-'
+%22 
 ).va
@@ -1954,17 +1954,18 @@
       $(
-'
+ %22
 #contact
@@ -1969,25 +1969,35 @@
 act_form
- 
+%22 ).find( %22
 textarea
 ').val('
@@ -1988,17 +1988,18 @@
 textarea
-'
+%22 
 ).val(''
@@ -1994,32 +1994,74 @@
 ea%22 ).val('');%0D%0A
+                    %0D%0A                  %0D%0A
                 
@@ -2341,34 +2341,30 @@
 form
- input, #contact_form 
+%22).find(%22input%22,%22
 text
+e
 area
@@ -2413,34 +2413,30 @@
 form
- input, #contact_form 
+%22).find(%22input%22,%22
 text
+e
 area

test JS best practices