2015-07-02 24 views
2

为什么引导程序中输入的必需属性不起作用?引导程序中输入的必需属性不起作用

<input type = "text" id = "thisisatext" class= "form-control" required> 
+0

我在网页上几个文本框。 –

+0

http://stackoverflow.com/questions/17163023/html5-required-validator-not-working-with-input-type-button –

+0

但我不使用提交按钮,我用

回答

0

使用这种类型的,它会工作Validator

<form data-toggle="validator" role="form"> 
 
    <div class="form-group"> 
 
    <label for="inputName" class="control-label">Name</label> 
 
    <input type="text" class="form-control" id="inputName" placeholder="Cina Saffary" required> 
 
    </div> 
 
    <div class="form-group"> 
 
    <label for="inputTwitter" class="control-label">Twitter</label> 
 
    <div class="input-group"> 
 
     <span class="input-group-addon">@</span> 
 
     <input type="text" pattern="^([_A-z0-9]){3,}$" maxlength="20" class="form-control" id="inputTwitter" placeholder="1000hz" required> 
 
    </div> 
 
    <span class="help-block with-errors">Up to 20 letters, numbers and underscores</span> 
 
    </div> 
 
    <div class="form-group"> 
 
    <label for="inputEmail" class="control-label">Email</label> 
 
    <input type="email" class="form-control" id="inputEmail" placeholder="Email" data-error="Bruh, that email address is invalid" required> 
 
    <div class="help-block with-errors"></div> 
 
    </div> 
 
    <div class="form-group"> 
 
    <label for="inputPassword" class="control-label">Password</label> 
 
    <div class="form-group col-sm-6"> 
 
     <input type="password" data-minlength="6" class="form-control" id="inputPassword" placeholder="Password" required> 
 
     <span class="help-block">Minimum of 6 characters</span> 
 
    </div> 
 
    <div class="form-group col-sm-6"> 
 
     <input type="password" class="form-control" id="inputPasswordConfirm" data-match="#inputPassword" data-match-error="Whoops, these don't match" placeholder="Confirm" required> 
 
     <div class="help-block with-errors"></div> 
 
    </div> 
 
    </div> 
 
    </div> 
 
    <div class="form-group"> 
 
    <div class="radio"> 
 
     <label> 
 
     <input type="radio" name="underwear" required> 
 
     Boxers 
 
     </label> 
 
    </div> 
 
    <div class="radio"> 
 
     <label> 
 
     <input type="radio" name="underwear" required> 
 
     Briefs 
 
     </label> 
 
    </div> 
 
    </div> 
 
    <div class="form-group"> 
 
    <div class="checkbox"> 
 
     <label> 
 
     <input type="checkbox" id="terms" data-error="Before you wreck yourself" required> 
 
     Check yourself 
 
     </label> 
 
     <div class="help-block with-errors"></div> 
 
    </div> 
 
    </div> 
 
    <div class="form-group"> 
 
    <button type="submit" class="btn btn-primary">Submit</button> 
 
    </div> 
 
</form>

+0

如果我不使用表单,该怎么办?我使用处理数据到javascript(Ajax)到PHP,这就是为什么我不使用提交表单。 –