Devil's Advocate Devil's Advocate - 1 year ago 125
Javascript Question

Detect changed input text box

I've looked at numerous other questions and found very simple answers, including the code below. I simply want to detect when someone changes the content of a text box but for some reason it's not working... I get no console errors. When I set a breakpoint in the browser at the change() function it never hits it. Entire page code below:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DatabaseAssociation.aspx.vb" Inherits="projectname.DatabaseAssociation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
<link href="add.css" rel="stylesheet" type="text/css" />
<script src="../JS/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="../JS/jquery-ui-1.8.13.custom.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
$('#inputDatabaseName').change(function () { alert('test'); });

<form id="form1" runat="server">
<input id="inputDatabaseName">
<table id="searchResults"><tr><td>empty</td></tr></table>

Answer Source

You can use oninput event like this:


Or like this:

<input id="inputDatabaseName" onchange="youFunction();"
onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download