未输入用户名密码点击登录时浏览器「Invalid Info」提示的移除方法咨询
Hey there! Let's tackle that pesky "Invalid Info" prompt popping up when you click login without entering a username or password. Since you haven't written any JS or PHP validation code, this is almost certainly coming from browser-native HTML5 form validation—here's how to turn it off:
1. Disable native validation for the entire form
The easiest way is to add the novalidate attribute directly to your <form> tag. This tells the browser to skip all built-in validation checks for that form entirely.
Example code:
<form action="your-login-handler.php" method="post" novalidate> <input type="text" name="username" placeholder="Enter username"> <input type="password" name="password" placeholder="Enter password"> <button type="submit">Login</button> </form>
2. Remove required attributes from individual fields
If the prompt is only triggered by specific fields (like ones marked with required), you can just delete the required attribute from those input elements.
For example, change this:
<input type="text" name="username" required>
To this:
<input type="text" name="username">
Either of these methods should stop the browser from showing that "Invalid Info" message when you submit the empty form. If you ever want to add custom validation later, you can do so with JavaScript, but for now, these quick fixes should do the trick!
内容的提问来源于stack exchange,提问作者Nadee

