title: How to pass an event object to a function in Javascript?
body: <pre><code>&lt;button type="button" value="click me" onclick="check_me();" /&gt;
  
  function check_me() {
    //event.preventDefault();
    var hello = document.myForm.username.value;
    var err = '';
  
    if(hello == '' || hello == null) {
      err = 'User name required';
    }
  
    if(err != '') { 
       alert(err); 
       $('username').focus(); 
       return false; 
     } else { 
      return true; }
  }
  </code></pre>
  
  <p>In Firefox, when I try to submit an empty value it throws up the error and sets the focus back to element. But same thing doesn't happen in IE as it throws up error and after clicking OK and posts the form (returns true).</p>
  
  <p>How I can avoid this? I was thinking to avoid this using <code>event.preventDefault()</code>, but I am not sure how to do this using this method. I tried passing <code>checkme(event)</code> .. but it didn't work. I am using Prototype js.</p>
  
  <p>(I know how to pass an event when I bind an .click function in Javascript.. instead of calling <code>onclick</code> within html .. using Jquery, but I have to debug this piece of code)</p>