W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap 实例</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h3>表单验证</h3> <p>请尝试提交表单。</p> <form action="/demo/html/action_page.php" class="was-validated"> <div class="mb-3 mt-3"> <label for="uname" class="form-label">用户名:</label> <input type="text" class="form-control" id="uname" placeholder="请输入用户名" name="uname" required> <div class="valid-feedback">有效的。</div> <div class="invalid-feedback">请填写此字段。</div> </div> <div class="mb-3"> <label for="pwd" class="form-label">密码:</label> <input type="password" class="form-control" id="pwd" placeholder="请输入密码" name="pswd" required> <div class="valid-feedback">有效的。</div> <div class="invalid-feedback">请填写此字段。</div> </div> <div class="form-check mb-3"> <input class="form-check-input" type="checkbox" id="myCheck" name="remember" required> <label class="form-check-label" for="myCheck">我同意这些条款。</label> <div class="valid-feedback">有效的。</div> <div class="invalid-feedback">选中此复选框以继续。</div> </div> <button type="submit" class="btn btn-primary">提交</button> </form> </div> </body> </html>