AngularJs: How to Format Data in an Input? - input

Problem
I need to format an input field visually in order to help the user know what they should type as a phone number. For example, I want to accept a phone number as being a 3 digit area code, 3 digit prefix and 4 digit suffix: (207) 555-1212. I want to:
provide the helper formatting to the input field -- those parentheses and the hyphen
I don't want the 'helper' characters to be included in the actual data I store in my model.
As the user types, I want the parentheses to magically appear, then have the hyphen also appear at the right point.
What's the best way to do it?
Note: This is not for displaying of a number -- I could use a filter for that. This is for formatting data within an input field.
Thanks for your help!

If you are looking for a simple solution, you could give AngularUI a try, http://angular-ui.github.com/
This is the example from the "Mask" section of that page:
<input ng-model="maskDemo" ui-mask="'99-99-9999'">
The "9"'s are numbers, and other stuff is just a mask / placeholders. It should only submit the actual values. You would edit the mask to include parentheses and anything else you may need.

Related

Add spacing between numbers after some specific digits in React Native

I need to show dashes as hints and need to have equal spacing after some digits in Text Input similar to the picture attached .
Do I need to use separate text inputs for these or is it possible to achieve this in a single input text field? The user should be able to enter the number in a single go.
If you know phone number format you can do it manually in one input. You are saving it as a real number, but displaying it with spaces. If you can have various formats, from various countries you can use this package https://www.npmjs.com/package/react-native-phone-number-input
The best way to achieve that is by using mask input you can use react-native-mask-input library to do it you can check the library from here.

NetSuite Grab any inventory numbers with lowercase letters in them

I am trying to make a saved search that shows any inventory numbers with lowercase letter(s) in it. I have tried the following formula but am not having any luck, I have tried using the match parameter but don't want to specify a position for where the lowercase letter may occur, could anyone tell me what I'm doing wrong and what I need to do to correct it?
REGEXP_INSTR({inventorynumber},'%[a-z]%')
I have this in a numeric formula criteria where it is not equal to 0.
In NetSuite Saved Search you do not need to use the wild card (%) with the character class ([]). The following 2 options should work.
REGEXP_INSTR({entityid},'[a-z]')
REGEXP_INSTR({entityid},'[[:lower:]]')

Is format ####0.000000 different to 0.000000?

I am working on some legacy code at the moment and have come across the following:
FooString = String.Format("{0:####0.000000}", FooDouble)
My question is, is the format string here, ####0.000000 any different from simply 0.000000?
I'm trying to generalize the return type of the function that sets FooDouble and so checking to make sure I don't break existing functionality hence trying to work out what the # add to it here.
I've run a couple tests in a toy program and couldn't see how the result was any different but maybe there's something I'm missing?
From MSDN
The "#" custom format specifier serves as a digit-placeholder symbol.
If the value that is being formatted has a digit in the position where
the "#" symbol appears in the format string, that digit is copied to
the result string. Otherwise, nothing is stored in that position in
the result string.
Note that this specifier never displays a zero that
is not a significant digit, even if zero is the only digit in the
string. It will display zero only if it is a significant digit in the
number that is being displayed.
Because you use one 0 before decimal separator 0.0 - both formats should return same result.

VB6 Change Numeric Field To Alphanumeric

There is a numeric field in a legacy application that I am trying to change to alphanumeric with a field length of about 15. The field is for data entry of account information. In the code, its referenced at numerous places:
.BANK_accno = Format(Me.txtBANK, "####-##-##-##-##")
and
!BANK_accno = Format(Me.txtBANK, "####-##-##-##-##")
The Format is: ####-##-##-##-## and the Mask is ####-##-##-##-##. What I am wondering is what Format (and code) changes should I make to get the field to become alphanumeric? I tried using ##########, however that has not worked.
As BobRodes commented, you can use # to mask characters not limited to numbers. There are other options (ignore spaces, force left-to-right filling, upper/lower case).
Have a look at Format function documentation at MSDN for details. This link is for VBA but Format strings should be compatible.
Please note that you still need to validate Input, Format function is not strict about input.

How to check if text in a UITextField matches a specific pattern?

I have a UITextField and I need to check, as the user types, if the text they have entered in the textfield so far matches a specific pattern.
More specifically, I need the text to match the pattern ####-##-## where # is any digit 0-9 and - is a dash (note that this is NOT a phone number or email). For example, the entry 1990-12-09 matches, 1990:12:09 does not match and 1990-12 DOES match because it has not yet violated the pattern (even though the text does not yet completely match the pattern).
How should I approach this? Ideally I would not have to hard code in a series of if statements .
The difficulty is that I want to check if the text in the textfield matches this pattern, as the user types. I don't want to just check it at the end.
I'm thinking that regular expressions are probably the way, but I'm not experienced enough at them to know if they hold the solution.
You could set the keyboard type to myTextField.keyboardType = UIKeyboardTypeNumberPad that why you are limiting the type of input.
Then this post should help answer your formatting question: UITextField format in xx-xx-xxx