Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to: Validate special characters?

(0) ShareShare
ReportReport
Posted on by 371

How to: Validate special characters in a filed that are not allow only alpha numeric value it accepts 

*This post is locked for comments

  • vinaytak Profile Picture
    371 on at
    RE: How to: Validate special characters?

    @André Arnaud de Calavon...lowercase characters are allowed if i use the code i have wriiten and i agree with all the suggestion u said to me..and i note also to use more and more the regular expression also....

  • Verified answer
    André Arnaud de Calavon Profile Picture
    294,430 Super User 2025 Season 1 on at
    RE: How to: Validate special characters?

    Hi Vinay,

    Is your question answered? If so, mark the replies that helped you.

    I want to make one additional note: The approach using regular expressions and strContains should be considered. Or you try to find some illegal characters (strContains), but the list might be incomplete. E.g. the character "o/oo" (Can't find it on  my keyboard right now) is not listed, so allowed. I haven't tried the suggestion from Crispin, so I can't comment if the code should be correct or not.

    Using regular expressions you tell which values are allowed. Also here you can have an incomplete list. In your example you used "A-Z 0-9". This is allowing capitals only. So lowercase characters are not allowed here.

    Regular expressions are very powerful. Last week we defined a formula to check a string field for a valid entered date, including check on days per month and a leap year.

  • Verified answer
    vinaytak Profile Picture
    371 on at
    RE: How to: Validate special characters?

    it done successfully after writing code in table method

    public boolean validateWrite()

    {

       boolean ret;

       TextBuffer txt = new TextBuffer();

       ret = super();

       txt.setText(this.teachername);

       txt.regularExpressions(true);

       if (txt.find("^[A-Z 0-9]+$"))

       {

           ret = true;//info("string contains only numbers");

       }

       else

       {

           this.teachername="";

           throw error(" Conatin the Special Character");

       }

       return ret;

    }

  • vinaytak Profile Picture
    371 on at
    RE: How to: Validate special characters?

    @Crispin John Augustine... I already done this also but not working donot the reason why the code is not restricted.. any special char in.....is there i also tried the txt buffer method but not working........

  • vinaytak Profile Picture
    371 on at
    RE: How to: Validate special characters?

    @Crispin John Augustine .... it doesnt throw any error also when i am done written it can easily move to the nxt field

  • vinaytak Profile Picture
    371 on at
    RE: How to: Validate special characters?

    i have written the code in the table

    public boolean validateField(FieldId _fieldIdToCheck)

    {

       String30        teachername;

       boolean ret;

       ret = super(_fieldIdToCheck);

       if(ret)

       {

           switch (_fieldIdToCheck)

           {

                case fieldNum (Validationtale,teachername):

                if(strContains(teachername,"!@#$%^&*()_+=-[{]};:',<.>/?/-*+"))

           {

               Box::info("Special Character Is not Allowed ");

                  return checkFailed(strFmt("Invaild characters"));

                  }

                    else

                       {

                       break;

                       }

           }

       }

    return ret;

    }

    but in form they are accepting the special charc....

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.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,430 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,043 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans