Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 仅允许在angularjs/ionic中键入一定数量的字符_Html_Angularjs_Validation_Angularjs Directive_Ionic Framework - Fatal编程技术网

Html 仅允许在angularjs/ionic中键入一定数量的字符

Html 仅允许在angularjs/ionic中键入一定数量的字符,html,angularjs,validation,angularjs-directive,ionic-framework,Html,Angularjs,Validation,Angularjs Directive,Ionic Framework,我有这个文本字段,我需要阻止用户输入超过允许的字符。假设我希望用户只键入10个字符,如果他键入更多字符,文本字段将不会接受它。在达到字符限制后,它必须停止获取输入 我知道存在ng maxlength,但它不会阻止用户键入超过允许的字符,尽管我可以给出错误消息。有没有办法做到这一点 我的文本字段 <div class="form-group" ng-class="{ 'has-error' : submitted && (thirdPartyForm.beneAcc.$

我有这个文本字段,我需要阻止用户输入超过允许的字符。假设我希望用户只键入10个字符,如果他键入更多字符,文本字段将不会接受它。在达到字符限制后,它必须停止获取输入

我知道存在ng maxlength,但它不会阻止用户键入超过允许的字符,尽管我可以给出错误消息。有没有办法做到这一点

我的文本字段

   <div class="form-group" ng-class="{ 'has-error' : submitted && (thirdPartyForm.beneAcc.$pristine || thirdPartyForm.beneAcc.$invalid )}">
                <label  class="labelColor"><h5><b>Beneficiary Account/Card Number*</b></h5></label>
                 <input  ng-keyup="validateCreditCard();" onkeypress="return ((event.charCode > 64 && event.charCode < 91) || (event.charCode > 96 && event.charCode < 123) || event.charCode == 8 || event.charCode == 45 || event.charCode == 32 || (event.charCode >= 48 && event.charCode <= 57))" type="{{inputType}}" ng-click="inputClick()"    id="beneAcc" name="beneAcc" ng-model="data.beneAcc" class="form-control"  ng-blur="validateDesitinationAccount(data.origin, data.beneAcc);" required>
                <span class="help-inline" ng-show="submitted && (thirdPartyForm.beneAcc.$pristine || thirdPartyForm.beneAcc.$invalid )">Beneficiary Account No cannot be left blank.</span>
                <span class="help-inline" ng-show="validateAccFlag" style="color:red" >{{validateMsgStr}}</span>
                <span class="help-inline" style="color:red;"  ng-if="LkrValidation">You cannot transfer Sri Lankan Rupees to foreign currency accounts.</span>
                <span class="help-inline" style="color:red;"  ng-show ="accountNoFlag">{{accountNoValidateMsg}}</span>
                </div>

受益人帐户/卡号*
受益人账号不能为空。
{{validatemsgsstr}}
您不能将斯里兰卡卢比转入外币账户。
{{accountNoValidateMsg}}

这是他们的文档

<input type="text"
   ng-model=""
   [name=""]
   [required=""]
   [ng-required=""]
   [ng-minlength=""]
   [ng-maxlength=""]
   [pattern=""]
   [ng-pattern=""]
   [ng-change=""]
   [ng-trim=""]>

您可能希望执行以下操作:

<input type="text" maxlength="10"/>

如果要将输入限制为特定长度,请使用maxlength而不是 ng最大长度

<input ng-model="num1" type="text" maxlength="3"></input>

提及

使用
maxlength

例如:
maxlength=“10”


此外,对于计数空白也使用
ng trim=“false”

是,这可以工作,但在type=“number”时不起作用。有没有办法解决这个问题?在IONIC2(离子输入)中不工作。。。有什么帮助吗?只有在键入“text”时才起作用。是否有办法解决type=“number”的问题??