[英]Ui mask partial value
Hi for the UI mask in angularui is there a way to only grab a portion of the value from the input box? 嗨,对于angularui中的UI掩码,有没有办法只从输入框中获取一部分值? For example: 例如:
<input type="text" name="myInput" ui-mask="999-999-9999" placeholder="xxx-xxx-xxxx"class="form-control" data-ng-model="search.phone" maxlength="12" ui-mask-use-viewvalue="true">
When I type 7783777826 it becomes 778-377-7826 (as specified by the ui-mask syntax). 当我输入7783777826时,它变为778-377-7826(由ui-mask语法指定)。
However when I type 778377782 or 778377 the value is null. 但是,当我键入778377782或778377时,该值为null。 I want it so that even if a user types these short values I can at least capture them . 我想要它,即使用户键入这些短值,我至少可以捕获它们。
Is it possible to grab these partial values via $viewValue? 是否可以通过$ viewValue获取这些部分值?
In the uiMask module, I ended up commenting out these lines from the blurHandler function, which allows partial values to be entered without them getting set to null if invalid. 在uiMask模块中,我最终在blurHandler函数中注释掉这些行,这允许输入部分值,如果无效则不会将它们设置为null。
function blurHandler(){
oldCaretPosition = 0;
oldSelectionLength = 0;
//if (!isValid || value.length === 0) {
// valueMasked = '';
// iElement.val('');
// scope.$apply(function (){
// controller.$setViewValue('');
// });
//}
}
I realize editing the library isn't the best option, but it may be what you were looking for. 我意识到编辑库不是最好的选择,但它可能就是你要找的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.