I have a sign up form. I want to implement some validation at client end itself. I am using a button to submit a form. 

```
<button onclick="check_fields();"></button>

 function check_fields() {          
       if(document.contact_form.name.value=='')                                                     
           document.contact_form.name.focus();
       else 
           document.getElementById("contact_form").submit();    
   }

```

Focus is not happening, instead form is successfully submitting. 
Please help.