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)

Field Validation using JavaScript

(0) ShareShare
ReportReport
Posted on by

Hello,

In our CRM we have to send a XML file to Department of State to have our records processed. But the DOS do not accept some special characters and we would like to implement field validation using JavaScript. I was able to find some sample codes for email validation, but I did not find it for regular text fields. Is there anyone that could help me achieve this?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    You can use following code:

    function ValidateSpecialChar()

    {

    var Regexp=/[^a-zA-Z0-9 ]/;  //this will allow space

    var value=Xrm.Page.getAttribute("name").getValue();

    if (Regexp.test(value)) {

     alert("Special Character is Not Allowed !!");

     Xrm.Page.getAttribute("name").setValue(null);

     }

    else {

       return false;

     }

    }

  • Community Member Profile Picture
    on at

    Can we allow these characters? ' - .

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