pav
9/23/2013 - 8:10 PM

validate_form..css

$(document).ready(function(){    
    $("#form").submit(function(event) {
        //I am preventing the default submit of the form so that the
        //page does not reload on complete. (this is the default action). You
        //could also return false from our handler to do the same thing. A 
        //useful application of this is to return true only on correct
        //validation, and false otherwise.That way the form only submits if true
        event.preventDefault();

        //YOUR CODE AFTER HERE
        
    var insert;
    if($('input[type="text"]').val() === "codecademy"){
        insert = "Correct!";
    }else{
        insert = "Error!";
    }
    $('#form span').text(insert).show().fadeOut(1000);
    });
});     
<html>

<head>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    <script src="script.js"></script>
</head>

<body>
 <p>What is the best site to learn JQuery?</p>
  <form id="form">
    <div>
      <input type="text" />

      <input type="submit" />
    </div>
  <span></span>
</body>

</html>
 p { margin:0; color:blue; }
  div,p { margin-left:10px; }
  span { color:red; }