Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    JohnAnonymous Profile Picture
    JohnAnonymous 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.

  • RE: cant read input value using jquery

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

  • RE: cant read input value using jquery

    I use Dyanmics 2015, on-premise.

  • 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

  • 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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans