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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

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

    community.dynamics.com/.../198412

  • Anchal Profile Picture
    on at

    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

  • Community Member Profile Picture
    on at

    Unfortunately I have got the same result(

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

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

    community.dynamics.com/.../185831

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi David,

    Please refer the link below.

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans