2015-11-01 44 views
3

我在bootstrap framework php頁面中有以下字段。使用模式屬性在自舉輸入字段中限制字符

<div class="col-xs-12 col-sm-10"> 
    <div class="form-group"> 
    <input type="text" name="inp_field1" id="inp_field1" class="form-control input-sm" placeholder="Do it here..." value='<?php echo($data_text_1)?>' required 
           data-toggle="tooltip" title="Do it here..." tabindex="3"> 
    </div> 
</div> 

我需要限制幾個字符說例如/ @。我如何限制特定字符。不尋找什麼可以允許的,但不能取而代之的是什麼。理想情況下,如果可以使用模式屬性來完成,那就太好了。

回答

1

嘗試

<div class="col-xs-12 col-sm-10"> 
    <div class="form-group"> 
    <input type="text" name="inp_field1" id="inp_field1" 
      class="form-control input-sm" 
      placeholder="Do it here..." value='<?php echo($data_text_1)?>' 
      required data-toggle="tooltip" title="Do it here..." 
      tabindex="3" 
      pattern="[^@\\]"> 
</div> 

+0

這是給高亮(紅色框)的字符,包括字母。當輸入受限字符時,通常會突出顯示 – user4826347

+0

這是否適用於safari? – pipalia

+0

是html5 ...是不是一個瀏覽器spefic ..然後應該工作 – scaisEdge