Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Crm Online JavaScript error: Xrm.Page.getControl(...).addOnKeyPress is not a function !?

Posted on by Microsoft Employee

function test() {

  
 function validateInput() {  
   //get the value of the name field  
   var input = Xrm.Page.getControl("new_testautocomplete").getValue();  
   if (input != "") {  
     //check if the last key pressed is a number  
     if (isNaN(input.substr(input.length - 1)) == false) {  
       //display the message  
       alert("Numeric values are not allowed in the account name");  
     }  
   }    
}

 try {

//attach the validateInput function to the keypress event of the name attribute  
 Xrm.Page.getControl("new_testautocomplete").addOnKeyPress(validateInput);
 } catch (e) {
           // console.log(e);
           alert(e);
 }

}
 

}

*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Crm Online JavaScript error: Xrm.Page.getControl(...).addOnKeyPress is not a function !?

    Hi David,

    Please refer the link below.

    community.dynamics.com/.../keypress-methods-in-ms-crm-2016

  • Suggested answer
    Andreas Cieslik Profile Picture
    Andreas Cieslik 9,265 on at
    RE: Crm Online JavaScript error: Xrm.Page.getControl(...).addOnKeyPress is not a function !?

    Then you are running into this issue because of using number field:

    community.dynamics.com/.../185831

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Crm Online JavaScript error: Xrm.Page.getControl(...).addOnKeyPress is not a function !?

    Unfortunately I have got the same result(

  • Anchal Profile Picture
    Anchal on at
    RE: Crm Online JavaScript error: Xrm.Page.getControl(...).addOnKeyPress is not a function !?

    David, uncheck your legacy form rendering option. Then you'll good to go. Settings -> Administration -> System Settings -> Beneath of General Tab and set it to 'No'

    2728.2017_2D00_06_2D00_26_5F00_17_2D00_57_2D00_38.png

  • Suggested answer
    Andreas Cieslik Profile Picture
    Andreas Cieslik 9,265 on at
    RE: Crm Online JavaScript error: Xrm.Page.getControl(...).addOnKeyPress is not a function !?

    Please check this thread, you might have the same issue here:

    community.dynamics.com/.../198412

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans