Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How do you implement an on change event for a text field in the Dynamics 365 Portal

(0) ShareShare
ReportReport
Posted on by 70

This one is driving me crazy.  I am trying to implement an onchange event on the telephone2 field in the Dynamics 365 portal, but it doesn't fire.  I tried putting $("#telephone2").on('change', HomePhone_OnChange());in the $(document).ready(function () {} block, but it fired when the form loaded and displayed a message from the JavaScript on a blank create form.  Then when I close the message and enter a value in the telephone2 field and tab out of the field, nothing happens.  I moved the $("#telephone2").on('change', HomePhone_OnChange()); out of the $(document).ready(function () {} block, which did remove the message on load, but changing the field value still did not trigger the on change event.  Can someone please describe to me how to implement an on change event in a portal form?

*This post is locked for comments

  • Suggested answer
    Priyanka Kamble Profile Picture
    20 on at
    RE: How do you implement an on change event for a text field in the Dynamics 365 Portal

    I got it worked with below script:

    $(document).ready(function () {

       $("#cld_sameaswebformsfirmadministrator").change(oncheckboxChange);

    });

    function oncheckboxChange() {

       if ($('#cld_sameaswebformsfirmadministrator').prop("checked") == true) {

           $("#cld_firstname2").val($("#firstname").val());

           $("#cld_lastname2").val($("#lastname").val());

           $("#cld_jobtitle2").val($("#jobtitle").val());

           $("#cld_emailaddress2").val($("#emailaddress1").val());

           $("#telephone3").val($("#cld_phone3").val());

       }

       else {

           $("#cld_firstname2").val('');

           $("#cld_lastname2").val('');

           $("#cld_jobtitle2").val('');

           $("#cld_emailaddress2").val('');

           $("#telephone3").val('');

       }

    }

  • Daniel Wikell Profile Picture
    2,360 on at
    RE: How do you implement an on change event for a text field in the Dynamics 365 Portal

    It is actually not all that strange as putting () after a function tells the engine to make a function call while the onchange function itself expects a parameter that is merely a function reference.

    By including it as " $("#title").change(onTitleChange()); " the parameter that is sent in to the change-function is not a function reference but instead the result of the call to onTitleChange() which is evaluated before. In your case the onTitleChange method returned nothing so it would be the same as doing "$("#title").change(undefined);"

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How do you implement an on change event for a text field in the Dynamics 365 Portal

    Glad it is resolve. Would appreciate if you could marke the suggestion as helpful and close the thread. This may help someone else as well :)

  • jimfield Profile Picture
    70 on at
    RE: How do you implement an on change event for a text field in the Dynamics 365 Portal

    Yes that helped.  I had () after the function name  in the .change statement, and the () throw it off and cause the function to fire on load and not when leaving the field.  If I remove the (), then the function fires when changing the actual field.  Strange.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How do you implement an on change event for a text field in the Dynamics 365 Portal

    Hi Jimfield,

    I tried the below code on the title field on the create case entity form and it is working as expcted. Try this code and see if this works. Also ensure that the is of the textbox is correct.

    ===========

    $(document).ready(function () {

     $("#title").change(onTitleChange);

     });

     function onTitleChange()

     {

     alert("changed111!!!");

     }

    ==============

    Hope this helps.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 54

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans