티스토리 뷰

💼 정보 ver1.0

.submit()

James Wetzel 2012. 9. 10. 14:03

<!DOCTYPE html>
<html>
<head>
 
<style>

  p
{ margin:0; color:blue; }
  div
,p { margin-left:10px; }
  span
{ color:red; }
 
</style>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 
<p>Type 'correct' to validate.</p>
 
<form action="javascript:alert('success!');">
   
<div>
     
<input type="text" />

     
<input type="submit" />
   
</div>
 
</form>
 
<span></span>
<script>

    $
("form").submit(function() {
     
if ($("input:first").val() == "correct") {
        $
("span").text("Validated...").show();
       
return true;
     
}
      $
("span").text("Not valid!").show().fadeOut(1000);
     
return false;
   
});
</script>

</body>
</html>

반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함