7

I currently have an input with a ui-mask for a phone. If the value that is inputted isn't the full length of the mask, it clears the input. Is there a way to set the ui-mask so that it doesn't clear the input upon clicking or losing focus?

<input ui-mask="(999) 999-9999" type="text"/>
Tyler Pflueger
  • 827
  • 2
  • 12
  • 17

3 Answers3

17

You can set a ui-options attribute that sets the option:

<input ui-mask="(999) 999-9999" ui-options="{clearOnBlur: false}" type="text" />
John Drouhard
  • 1,209
  • 2
  • 12
  • 18
0

I didn't really find the exact answer I wanted but this is the solution I went with.

<input ui-mask="?(999) 999-9999" type="text"/>

Just so I could use the ui-mask and it wouldn't clear the field.

Tyler Pflueger
  • 827
  • 2
  • 12
  • 17
0

Per the docs, you can achieve this globally in your application using app.config()and the options available:

app.config(['uiMask.ConfigProvider', function(uiMaskConfigProvider) {
  uiMaskConfigProvider.clearOnBlur(false);
}]);

Here's the full list of options: ui-mask options

Dylan Pierce
  • 4,313
  • 3
  • 35
  • 45