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)

CRM Form Input data validation

(0) ShareShare
ReportReport
Posted on by 2,601

Is there a best practice to validate data as it's being input?

For example for email/phone numbers, I can detect that the input isn't in the correct format and show an alert informing the user of this. But, then how should I ensure the user acts on this?

One option would be to empty the field making them entering it again.  

I think Ideally I'd want to keep the focus on the field until it passes validation.  

Also, could I use Business Rules?  From what I've seen though they can't access javascript code

TIA

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    jlattimer Profile Picture
    24,562 on at

    If you really want to enforce a standard outside of the normal data type validation CRM already provides you'd want use some JavaScript during the OnSave event of the form to validate the field(s) and prevent the save or alternatively do the same thing using a plugin or a real-time workflow. 

  • Verified answer
    Hosk Profile Picture
    on at

    Javascript validation would probably be your best method for email/phone validation.

    The reason JavaScript is probably best suited is because phone validation can be quite complex (e.g. starts with certain numbers, international code, spaces, length) and this is very hard to do using a business rule

    You can trigger Javascript on the onchange of a field, this means it will be triggered after the user has typed something in and then clicked onto another field.

    You can also put some Javascript on the Onsave of the entity to prevent the values being saved until the user has put in a valid email\phone number

  • Community Member Profile Picture
    on at

    I would like to add to confirm my understanding and scope of validation, with javascript, we can do the validation when the data is added from user interface (Client). Any data that gets loaded via back end process will not be validated resulting in unexpected data values.

    Harihar

  • Suggested answer
    Hosk Profile Picture
    on at

    you are correct Javascript validation is client side and doesn't get triggered when data is updated via imports, bulk updates.

    Client side code also doesn't get triggered when plugins update data.

    Plugins, workflows are server side

    javascript, business rules are client side and only run when entity is updated using the GUI /FORM interface.

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