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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

cant read input value using jquery

(0) ShareShare
ReportReport
Posted on by

Hi

Tol validate form inputs, I use js and jquery, to validate if a text input is number or .... 

I registered .focus-in (using jquery) event for input element on form. The weird thing is that it is being called either on focus-in and focus-out! 

  $("#mobilephone").on('focusin', function() {
        // On first focus, check to see if we have the default text saved
        // If not, save current value to data()
        
        
        console.log($("#mobilephone").val());
        
        console.log(Xrm.Page.getAttribute("mobilephone").getValue());

        
    });


But the problem is that,  $("#mobilephone").val() always reutnr empty string but in the mean time Xrm.Page.getAttribute("mobilephone").getValue()

 returns entered input text. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    JohnAnonymous Profile Picture
    5,241 on at
    RE: cant read input value using jquery

    There's no supported way to do that. That functionality has only been introduced with 2016 as Guido mentioned.

    If you really need validation, the only way is to create a web resource, have your own validation and put the result in the text field.

  • Community Member Profile Picture
    on at
    RE: cant read input value using jquery

    I Use Dynamics CRM ver 2015. Is there anyway for that ?

  • Community Member Profile Picture
    on at
    RE: cant read input value using jquery

    I use Dyanmics 2015, on-premise.

  • Community Member Profile Picture
    on at
    RE: cant read input value using jquery

    For CRM 2016, you can use

    Xrm.Page.getControl(“mobilephone”).addOnKeyPress("your function after focus lost");

    For version before CRM 2016

    you can use the onchange event of the mobilephone field. Add a function in the main JS file and trigger the function by the field change event.

    Check this similar issue for more details:

    community.dynamics.com/.../185945

  • Community Member Profile Picture
    on at
    RE: cant read input value using jquery

    So is there any way that At least I check the user input when input loses its focus ?

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans