Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:43:34+00:00 2026-06-03T23:43:34+00:00

I need to detect if the value inside a textbox is changed . If

  • 0

I need to detect if the value inside a textbox is changed .
If the textbox contents are changed/Modified,I need to show a textBox and force the user to enter some comments about the change.

Here is my EditorTemplate page located at Shared/EditorTemplates/Addresses.cshtml

@Html.EditorFor(model => model.Address)
@Html.ValidationMessageFor(model => model.model.Address))
@Html.EditorFor(model => model.Comments,new{style="Visible:false" })
@Html.ValidationMessageFor(model => model.Comments ,new{style="Visible:false" })

Here is MyPage.cshtml where I call the above EditorTemplate

 @if (!UtilityHelper.IsNullOrEmpty(Model.AddressesRecords))
        {

             @Html.EditorFor(model => model.AddressesRecords)

         }

     <input type="submit" name="ButtonCommand" value="Save" />

When the page gets loaded ,there will be multiple address text boxes. If the User makes any modification to the any of the address TextBox,immediately CommentsTextBox will be made visible againt that particular address TextBox ,and validation is enabled.

So when I click Save button,I need to ensure that the user typed some comments in the CommentsTextBox.
If the user Clicks save button without Changing address text box,the records will just get saved.

During runtime ,I can see the editor id’s are dynamically generated like AddressesRecords_0_Address ,AddressesRecords_1_Address ……

I tried with some Jquery,but this never seems to work as the actual AddressTextBox ids are dynamically generated.

<script type="text/javascript">


    $(document).ready(function(){

       var $el = $('#AddressesRecords_0_Address');
       $el.data('oldVal',  $el.val() );


       $el.change(function(){

            $("#AddressesRecords_0_Comments").show();
       })

    });
</script>

Here how do I attach my Jquery change function against each of my addressTextBox ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:43:35+00:00Added an answer on June 3, 2026 at 11:43 pm

    Assuming I have 3 different textboxes named TextBox1, TextBox2, and TextBox3 this code will check for any change in those fields and show the Comments field

    $('#TextBox1, #TextBox2, #TextBox3').each(function () {
        $(this).data('oldVal', $(this).val());
        $(this).bind("propertychange keyup input paste", function (event) {
            if ($(this).data('oldVal') != $(this).val()) {
                $(this).data('oldVal', $(this).val());
    
                $('#Comments').show();
            }
        });
    });
    

    You could also assign a class to each of the fields and do it like this

    $('.MyClass').each(function () {
        $(this).data('oldVal', $(this).val());
        $(this).bind("propertychange keyup input paste", function (event) {
            if ($(this).data('oldVal') != $(this).val()) {
                $(this).data('oldVal', $(this).val());
    
                $('#Comments').show();
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to detect if a request cookie - value is different from a
I need to detect information about the Application Server my EJBs are running in.
I need to detect if a flag is set within an enum value, which
I'm looking for the algorithm (C#) or some info about how detect the edge
When a user clicks on my green button, I need Javascript to detect this
I am downloading URLs in Python and need to detect 404s, so after some
Is there is any way to detect text box value changed , whether users
I have a list of key/value pairs and I need to detect chains in
I need to detect which version of SQL I am dealing with to perorm
I need to detect and eval the Javascript code contained in a string. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.