if (document.getElementById('<%=txtName.ClientID %>').value == "" && document.getElementById('<%=txtPassword.ClientID %>').value == "")
{
alert("Enter Username & Password");
return false;
}
In most languages if you don't put braces to open and close the scope of the condition to be checked it only affects the first line after the condition.
As CPallini said, put the alert before the return.
And put the {} in the condition.
Hope this helps.