Hi for the UI mask in angularui is there a way to only grab a portion of the value from the input box? 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).
However when I type 778377782 or 778377 the value is 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?
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.