title: Javascript alert displaying as soon as the page loads
body: <p>I'm a newbee in Javascript.
  The error in the following code is that the alert message is displayed as soon as the page loads. Please help me overcome this error. And when I hit the submit button, the alert isn't displayed but rather the next link is opened.</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;Delete Book&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" media="screen" href="css/default.css" /&gt;
  &lt;/head&gt;
  &lt;body id="index_page"&gt;
  &lt;div id="wrapper"&gt;
      &lt;div id="header"&gt;
          &lt;h1 align="left"&gt;Library&lt;/h1&gt;
      &lt;/div&gt; 
      &lt;ul id="navigation"&gt;
          &lt;li id="index"&gt;&lt;a href="http://localhost/UID/FAQ.php"&gt;FAQ&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;div id="content"&gt;
      &lt;div id="main_content"&gt;
      &lt;h2&gt;Delete book&lt;/h2&gt;
   &lt;h4&gt;Enter details of the book&lt;/h4&gt;
   &lt;FORM action="del_book_action.php" method="post" &gt;
    &lt;TABLE WIDTH="70%" &gt;
  
    &lt;TR&gt;
        &lt;TH width="60%"&gt;Enter book ID:&lt;/TH&gt;
        &lt;TD width="50%"&gt;&lt;INPUT TYPE="text" name="id" id="book_id"&gt;&lt;/TD&gt;
    &lt;/tr&gt;
    &lt;TR&gt;
        &lt;TH&gt;&lt;/TH&gt;
        &lt;TD width="50%"&gt;&lt;INPUT TYPE="submit" Value="Submit"         onclick="validate_f()"&gt;&lt;/TD&gt;
    &lt;/tr&gt;
    &lt;/TABLE&gt;
   &lt;/FORM&gt;
  
  &lt;/div&gt;
  &lt;p id="footer"&gt;&lt;a href="http://localhost/UID/UID.php"&gt;@AntonyAjay,2012&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;script language="javascript"&gt;
  window.onload=function validate_f()
  {
   var y=document.getElementById("book_id").value;
   if(y==""||isNaN(x))
  {
  alert("Book Id should be numeric");
  }
   }
  &lt;/script&gt;
  
   &lt;/body&gt; 
    &lt;/html&gt;
  </code></pre>