我有以下Bootstrap标记:
<!-- Text input--> <div class="form-group"> <label class="col-md-4 control-label" for="username">Username</label> <div class="col-md-4"> <input id="username" name="username" type="text" placeholder="" class="form-control input-md" required="" maxlength="8" value=""> </div> </div> <!-- Button (Double) --> <div class="form-group"> <label class="col-md-4 control-label" for="submit"></label> <div class="col-md-8"> <button id="submit" name="submit" class="btn btn-primary" value="1">Create Profile</button> <button id="cancel" name="cancel" class="btn btn-default" value="1">Cancel</button> </div> </div>
当我单击“创建配置文件”按钮时,表单工作正常,让我知道某些字段是“必需”.但是当我单击“取消”按钮时,由于必填字段不完整,我无法退出表单.
Bootstrap中是否有表单取消按钮功能?
解决方法
将您的代码更改为以下内容:
<!-- Button (Double) --> <div class="form-group"> <label class="col-md-4 control-label" for="submit"></label> <div class="col-md-8"> <button id="submit" name="submit" class="btn btn-primary" value="1">Create Profile</button> <a href="javascript:void()" class="outlink" data="/link-to/whatever-address/" id="cancel" name="cancel" class="btn btn-default">Cancel</a> </div> </div>