My purpose: If the user field and password field are blank, I want to stop form submitting. This is my Code that I am trying:
onsubmit event accepts boolean values, since you are not returning anything so it assumes true by default. You need to add return in this event explicitly like mentioned below:
onsubmit
change
onsubmit="doit()">
to
onsubmit="return doit()">