Prevent use of filter characters in No. field

colingbradleycolingbradley Member Posts: 162
I have a client who has used the & character in the customer No. field and need to prevent them doing so in future.

As they enter the No., I need to test the No. and if I find any reserved filter characters, issue a warning or ERROR(msg);

What is the best way to search for these characters (% + - | = .. ? @ <> *)?

TIA,

Colin
Experience is what you get when you hoped to get money

Comments

  • SavatageSavatage Member Posts: 7,142
    You can clean the entry up .. like this.

    TempText := DELCHR(TempText,'=','-_+=\|[]}{".,#$@%^&amp;*+!~`:;/?><');

    or fill in the ValuesAllowed property of the field with only the characters you want 1,2,3,4,5,6,7,8,9,0,A,B,C,D....ETC. This will pop a message if a non listed character is entered.

    Or use a similar code as above but opposite. DELCHR all the characters you want and if the result is not blank then ERROR.
  • colingbradleycolingbradley Member Posts: 162
    (My help text says use the semicolon).

    The Values Allowed does not work that way as far as I can tell, I have:
    0;1;2;3;4;5;6;7;8;9;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;1234

    But trying to enter a No. of 1A gives an error saying that is not allowed. 1234 IS allowed.

    Presumably you would have to have every possible combination set up?

    Ideally, I would like to get any reserved characters and display them in the error message.
    Experience is what you get when you hoped to get money
  • colingbradleycolingbradley Member Posts: 162
    CharAllowed works.
    0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
    That does it for me, the message is automatic if any other character is used.
    Experience is what you get when you hoped to get money
  • David_SingletonDavid_Singleton Member Posts: 5,479
    (My help text says use the semicolon).

    The Values Allowed does not work that way as far as I can tell, I have:
    0;1;2;3;4;5;6;7;8;9;A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;1234

    But trying to enter a No. of 1A gives an error saying that is not allowed. 1234 IS allowed.

    Presumably you would have to have every possible combination set up?

    Ideally, I would like to get any reserved characters and display them in the error message.

    I think the string needs to be:
    azAZ09
    
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Oh and if you want to do it in code, then you can use Harry's example like this:
    If "No." <> DELCHR("No.",'=','-_+=\|[]}{".,#$@%^&*+!~`:;/?><') THEN
      error('-_+=\|[]}{".,#$@%^&*+!~`:;/?>< are not allowed');
    

    (though the \ probably wont show in the message but you can play with that.)
    David Singleton
  • colingbradleycolingbradley Member Posts: 162
    Oh and if you want to do it in code, then you can use Harry's example like this:
    If "No." <> DELCHR("No.",'=','-_+=\|[]}{".,#$@%^&*+!~`:;/?><') THEN
      error('-_+=\|[]}{".,#$@%^&*+!~`:;/?>< are not allowed');
    

    (though the \ probably wont show in the message but you can play with that.)

    The CharAllowed error message does show the \ so seems to be a good option but thanks David for you excellent response as always.
    Experience is what you get when you hoped to get money
  • SavatageSavatage Member Posts: 7,142
    Ooops Values Allowed - I ment CharAllowed :oops:
Sign In or Register to comment.