If you were to click on the My Account page > Login > Login & If you were to click on the Register page > Register Now! > Sign up.
It both goes an error page such as error page at My account page & error page at register page respectively.
Any idea how I can change the link of the two buttons to another page?
You should use
location.href = "https://www.w3schools.com";
after checks. here is source: https://www.w3schools.com/jsref/prop_loc_href.asp