My recommendation: Keep your existing registration-page JavaScript. It is useful for immediate feedback. Enforce the same validation independently in register-submit.php because server-side validation is the actual security boundary. Send me your complete register-submit.php code. I can identify exactly why mismatched passwords are currently being accepted and correct the entire submission flow without disturbing your existing CSRF, honeypot, rate-limiting and registration logic.