I m trying to autofocus on field when user submit empty or wrong data means compare to regex i have defined in code my php code is here
if (empty($_POST["password"])) {
$passwordErr = "Name is required";
$_POST["password"].focus();
} else {
$password = test_input($_POST["password"]);
}
plz guide me to solve this issue thanks
</div>
The $_POST["password"]
stands for read input variable 'password'
on server. It has no relation to the input field in the browser window.
If you want to focus the input field it has to be done on client side. This means some JavaScript has to validate the result of the AJAX call (if you used one to send the request) or you have to echo the JavaScript code (like suggested by @Dave Chen).