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 6132523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:06:46+00:00 2026-05-23T17:06:46+00:00

I’m used to programming in C# and I frequently bind to the TextChanged event,

  • 0

I’m used to programming in C# and I frequently bind to the TextChanged event, for example textBox.TextChanged. This would be triggered the moment the user or the program or anything else causes the contents of the text box to change.

I’m having a little problem with my HTML form. There are some AJAX things happening, and some javascript validation. These things need to happen when the user makes their changes, however the events are only firing on certain conditions.

For example, I have a drop down menu:

<select name="costCtr" id="costCentres" onchange="loadWorkers()">
  <?php echo $costCentreOptions; ?>
</select>

The expected result is that when the cost centre selection changes, the workers will be populated. This is not the case. If the user tabs to the dropdown menu and uses the keyboard to select the option, nothing happens! The only way to fire the event is to select the option by mouse, or to select the option with the keyboard and then press enter.

Similarly, I have a text field for a date, and a button next to it which shows a groovy javascript-based date-time-picker. It goes a little like this:

<input type="text" name="date" id="date" onchange="validateForm()" />

If the user clicks the button to show the date-time-picker, selects a date, clicks ok, and the date-time-picker drops the date string into the input field, the onchange event isn’t fired. In fact, the onchange event is only fired if the use changes the text by hand and then focuses away from the input field!

How do other web developers handle these events? Which events should I be binding to? Should I bind to body.onkeypress and then write a mountain of code to determine what, if anything, has changed and act accordingly? Other ideas?

  • 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-05-23T17:06:47+00:00Added an answer on May 23, 2026 at 5:06 pm

    For <select> elements, I always use onkeyup in conjunction with onchange, like:

    <select name="costCtr" id="costCentres" onchange="loadWorkers()" onkeyup="this.onchange()">
      <?php echo $costCentreOptions; ?>
    </select>
    

    …which will properly capture changes made using the keyboard.

    For text fields, you can again use onkeyup if you want to validate the input as the user types, or onblur if you want to validate when the user tries to leave the field, like:

    <input type="text" name="date" id="date" onkeyup="validateCurrentFieldValue()" />
    

    …or:

    <input type="text" name="date" id="date" onblur="validateForm()" />
    

    For text fields that are being used with a scripted date-picker, the best way to capture the selection event will depend upon your date-picker script. You should check its documentation to see what it says about capturing onchange/onselection events from the picker.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string

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.