Forcing Alpha Character Entry
NavTime
Member Posts: 18
I have a code field and my client requires an error if anything but an alpha character is entered. Does anybody have any experience or idea how to approach this? Thanks for the help.
0
Answers
-
This should help you along your way.
OBJECT Form 50900 ValidateLetters { OBJECT-PROPERTIES { Date=07/14/09; Time=[ 1:53:03 PM]; Modified=Yes; Version List=; } PROPERTIES { Width=8000; Height=8000; } CONTROLS { { 1000000000;TextBox;4510 ;550 ;1700 ;440 ;SourceExpr=TestInput; OnValidate=BEGIN Valid := LetterValidate(TestInput); END; } { 1000000001;Label ;1100 ;550 ;3300 ;440 ;ParentControl=1000000000 } { 1000000002;TextBox;4510 ;1210 ;1700 ;440 ;SourceExpr=ResultASCII } { 1000000003;Label ;1100 ;1210 ;3300 ;440 ;ParentControl=1000000002 } { 1000000006;CheckBox;4510;2090 ;440 ;440 ;ShowCaption=No; SourceExpr=Valid } { 1000000007;Label ;1100 ;2090 ;3300 ;440 ;ParentControl=1000000006 } } CODE { VAR TestInput@1000000000 : Text[30]; myChar@1000000001 : Char; ResultASCII@1000000002 : Integer; Valid@1000000003 : Boolean; PROCEDURE LetterValidate@1000000000(Text@1000000000 : Text[100]) : Boolean; VAR i@1000000001 : Integer; BEGIN FOR i := 1 TO STRLEN(Text) DO BEGIN myChar := Text[i]; ResultASCII := myChar; IF NOT (myChar IN [65..99,97..122]) THEN EXIT(FALSE); END; EXIT(TRUE); END; BEGIN END. } }
Char is your friend in this case, most likely.JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
Awesome. You the man!!! Thanks!!!!0
-
Cool. Edit the 1st post and mark it [Solved] (drop box right below Subject).
:thumbsup:JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
How about the property of the field -> CharAllowed.
enter AZaz0 -
^ MVP right answer trumps my 'would work' function.JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
It works too but I need to control the error message so the first solution works better for me.0
-
There are usually multiple ways to skin-a-cat w/Nav 8)0
-
Thanks for both solutions.
Question to MVP... how did you know to specify AZaz? Where did you get that information? I tried that property but didn't know what values to supply it with.0 -
If you go into the properties of the Form Textbox or the table's field, you'll see CharAllowed in the list. F1 in that field brings up the info:If you want users to only enter uppercase letters in this field, enter AZ. This ensures that only uppercase characters in the range of A-Z are accepted. If you want both uppercase and lowercase characters, leave this value blank.
You can specify multiple ranges of characters by entering the parameters in pairs. For example, a value of admpzz indicates that only the following characters are accepted: a, b, c, d, m, n, o, p, and z. If you only want to allow a single character, then enter that character twice to specify a starting and ending range.
For text boxes, you can use this property to further limit the characters allowed, based on the field's setting.
The setting for the text box and the field is checked during validation.
I've never had to use it, so I looked it up also.
JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
I did the same but F1 didn't come up with the same help text for me. Is there something else I need to do get that same help text as you?0
-
click on the property name "CharsAllowed" & hit F1
the help says AZIf you want users to only enter uppercase letters in this field, enter AZ
so I threw in the lowercase az to cover my bases
0 -
NavTime wrote:I did the same but F1 didn't come up with the same help text for me. Is there something else I need to do get that same help text as you?
If you're using a version that isn't NAV2009, F1 in field properties often just drops you at the generic "Welcome to Microsoft Dynamics NAV Online Help". But if that's the case, this thread, while still accurate, should live over there.
Open the Help menu, and go to C/SIDE reference. Search tab, type 'CharAllowed' and search. There be the help text you seek.JEREMY VYSKA
CEO, Spare Brained Ideas, Göteborg, Sweden
New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"0 -
[Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 327 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions