You can try below code which fetches the value from text boxes using the id in JavaScript.
function Button1_onclick() {
if (document.getElementById('txtUserName').value == "Admin" && document.getElementById('txtPassword').value == "123") {
//Login as Hardcoded User
//Do your stuff
window.location.assign("Search.aspx")
}
else {
window.location.assign("ResultDetails.aspx")
}
}