sansid
sansid

Reputation: 585

OnChange Event not firing

I have a textbox for which the value is loaded through a modal form. Everytime the text changes, I want the OnChange event to trigger and enable a button. My OnChange event does not seem to fire. My Javascript and the code is given below:

$("#txtFileName").change(function () {
    var selectedvalue = $("#FileGuid").val();
    alert(selectedvalue);           
});

<div class="editor-field modFileLoad">
  <%: Html.HiddenFor(model => model.FileGuid, new { @class = "flGuid",Visible=false })>
  <%: Html.TextBoxFor_Readonly(model => model.FileName, new{id= "txtFileName",style    = "width:400px;", @class = "flName" })%>  
</div>

Upvotes: 0

Views: 2887

Answers (1)

Ahsan Khurshid
Ahsan Khurshid

Reputation: 9469

Use .keyUp() event instead of .change() event.

.change() only fires when focus moves out from an element.

Example:

$("#txtFileName").keyUp(function () {
    var selectedvalue = $("#FileGuid").val();
    alert(selectedvalue);           
});

Upvotes: 1

Related Questions