web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Simple text field with minimum characters.

(0) ShareShare
ReportReport
Posted on by 45

Hi everybody,

Im looking for a solution for my problem:

I want a simple text field in de contact entity, with a minimum AND Maximum characters lenght of 5.

now it is possible to specify a maximum. but not to indicate a minimum. The format of the form must be (days / months). So from 01-01 to 31-12. Preferably with the first two values ​​that can go up to 31 and the last two values ​​to 12. But just a minimum would solve a large part of the problem.

I understood that this might be possible through javascript in the onchange event?

If this is not recommended because it is too much work, then I would also like to hear that.

Regards,
Daimy Tamis

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    Hi,

    I think you can create Javascript and put onchange event on that attribute. Then you can use Regex or just use traditional way (split by '/', parseToInt to check if the value is int or not and check the length <= 5 or not).

    stackoverflow.com/.../regular-expression-for-two-digit-month-and-two-digit-day-only

    Is not to difficult and you can handle it using Javascript.

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi Daimy Tamis,

    It can be done with On Change JavaScript. The rough process for creating the JavaScript is as follows.

    1. Create a JavaScript file that runs On Change of your simple text field.
    2. With the JavaScript code, retrieve the value of your simple text field, check its length, and prevent save of the field if it does not contain five or more characters.

    This is a basic example of a JavaScript function that can accomplish this.

    function FieldValidation(context)
    {
        var field = Xrm.Page.getAttribute("field").getValue();
        if(field.length < 5)   {
            Xrm.Utility.alertDialog("Please enter five or more characters in field");
            context.getEventArgs().preventDefault();
        }
    }

    However, it sounds like you are working with date values. Consider creating a Date and Time field before trying to solve this problem with JavaScript.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Daimy ,

    I understand your problem , but unfortunately there is no way to define your specific business logic without code. You need to write JS code for that ,there is no other options .

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    This can be/ should be achieved by JS.  You can tweek the above suggested sample code as per your requirements.

    Hope this helps.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans