dsvyc66464 2015-07-21 19:04
浏览 112
已采纳

使用Bootstrap验证来验证表单字段

I hope you all can give me a push in the right direction. I am creating a form using html/css & bootstrap. The form works kind of but I would like to use the validation states bootstrap offers. How do I use this in the right way? A field only should go green when it's correctly filled and red when an error occurs.

Can anyone give me an example on how I can show the correct state? (so green when correctly filled, red when not)

<div class="container">
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="row">
<div class="col-xs-3" style="padding-right:5px;">
  <label for="ex1"  ></label>
  <input class="form-control inputForm" id="ex1" name="voornaam" type="text" placeholder="Voornaam">
</div>
<div class="col-xs-3" style="padding-left:5px;">
  <label for="ex2"></label>
  <input class="form-control inputForm" id="ex2" type="text" name="achternaam" placeholder="Achternaam">   </div> </div><div class="row">


<div class="col-xs-6">
  <label for="ex3"></label>
  <input class="form-control inputForm" id="ex3" name="email" type="text" placeholder="Voer je e-mailadres in">

  </div></div>

<div class="row">


<div class="col-xs-6">
  <label for="ex3"></label>
  <input class="form-control inputForm" id="ex3"  name="wachtwoord" type="password" placeholder="Wachtwoord">
</div></div>

<div class="row">


<div class="col-xs-6">

  <input class="btn btn-primary btn-lg active" type="submit"  value="Registeren" style="Float: right; margin-top: 15px; width: 100%;">
</div></div>
</form>
</div>
  • 写回答

1条回答 默认 最新

  • dronthpi05943 2015-07-21 19:33
    关注

    Use classes .has-warning, .has-error, or .has-success.

    Error state:

    <input class="form-control inputForm has-error" id="ex1" name="voornaam" type="text" placeholder="Voornaam">
    

    Correct state:

    <input class="form-control inputForm has-success" id="ex1" name="voornaam" type="text" placeholder="Voornaam">
    

    http://getbootstrap.com/css/#forms-control-validation

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥200 求能开发抖音自动回复卡片的软件
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。