PHP exit message as bubble alert [closed]

I have a registration form and when someone not filling some row correctly it gets an error message, but it redirects to another page. I don’t want that. I want to display this message as a bubble next to the field.

if (strlen($_POST['password']) > 20 || strlen($_POST['password']) < 5) {
    exit('Your password must be between 5 and 15 characters!');
}

How should I modify the exit() line?

Thank you!