if(form.name.value==" " && form.password.value==" "){
Should be
if(form.username.value=="" && form.password.value==""){
|| is the OR and of course && is AND. Had you used || If either the password OR the name been blank it would have given the Alert. Using AND both have to be blank to get the Alert so your logic actually need to be to work correctly.
if(form.username.value=="" || form.password.value==""){
To test and see what I mean enter anything even a space into the username and the script will not show the Alert and carry on to the PHP script.