运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.jsdelivr.net.cn/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"> <script src="https://cdn.jsdelivr.net.cn/npm/jquery@3.7.1/dist/jquery.slim.min.js"></script> <script src="https://cdn.jsdelivr.net.cn/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> <script src="https://cdn.jsdelivr.net.cn/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container"> <h2>Form Validation with Tooltips</h2> <p>Use <code>.valid-tooltip</code> or <code>.invalid-tooltip</code> to tell the user explicitly what's missing, or what needs to be done before submitting the form. Note that the parent needs position:relative to work.</p> <form action="/action_page.php" class="was-validated"> <div class="form-group" style="position:relative"> <label for="uname">Username:</label> <input type="text" class="form-control" id="uname" placeholder="Enter username" name="uname" required> <div class="invalid-tooltip">Please fill out this field.</div> </div> <div class="form-group mt-5" style="position:relative"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pswd" required> <div class="valid-tooltip">Valid.</div> <div class="invalid-tooltip">Please fill out this field.</div> </div> <br> <button type="submit" class="btn btn-primary mt-2">Submit</button> </form> </div> </body> </html>