Notifications
Announcements
No record found.
I want to have XXX-XX-XXXX pattern automatically genrated in my string control in my form, so, as the user enter's the value e.g. 123456789, it automatically show's 123-45-6789.
regards,
*This post is locked for comments
You can use an edit method with something like (not the same formatting, but that's detail).
[code]edit str editMyString(boolean _set, str _value){ //format string in XXX-XXX-XXX..... str _format(str _unformatted) { str formatted; int i,len; ; len = strlen(_unformatted); for(i=1;i<=len;i+=3) { formatted += (formatted ? '-' : '')+substr(_unformatted,i,3); } return formatted; } ; if (_set) { //store string without formatting myString = strrem(_value,'-'); } //display a formatted string return _format(myString);}[/code]
In your edit-method you can also use NumberSeq::numInsertFormat() with a format string like "###-##-####"
That's detail, but I didn't know that one.
One thing to keep in mind though is that NumberSeq::numInsertFormat() returns type Num and therefor is limited to the length of this EDT (20 chars in my case).
Another drawback of using this method is that it takes an Integer as parameter, so formatting a string like 123AB839 to 123-AB-839 is not possible.
Hi,
Thnx Xander Vink & gl00mie. The information was very useful.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2