Jquery is not displaying the value of a textbox located in a user control

tagertez

New Member
I have this textbox located inside a gridview which is located in a user control. I'm trying to check whether a textbox is empty, using the below jquery code.\[code\]$(document).ready(function () {//when Dom is ready to be used $('input[type=submit]').click(function () { CheckIfCheckBoxIsChecked(this); //Use the clicked button to proceed }); });function CheckIfCheckBoxIsChecked(e) { var $id = $(e).prop('id'); //get the id of the clicked button var $gvid = "";//Set the name of the gridviewif ($id.indexOf('IT') != -1) { $gvid = "contentMain_cklistIT_gvCKList";}else if ($id.indexOf('HR') != -1) { $gvid = "contentMain_cklistHR_gvCKList";}else if ($id.indexOf('Marketing') != -1) { $gvid = "contentMain_cklistMarketing_gvCKList";}else if ($id.indexOf('Payroll') != -1) { $gvid = "contentMain_cklistPayroll_gvCKList";}else if ($id.indexOf('Property') != -1) { $gvid = "contentMain_cklistProperty_gvCKList";}var $AllHM = $('#' + $gvid + ' input[id*="ckHMreq"]:checkbox:checked'); //select only checked checkboxes that have ckHMreq as part of their name var n = $AllHM.length;if (n == 0) {//If there's none, telle the user alert('Please check at least one row to proceed');}else {//If there's at least one $.each($AllHM, function () {//Loop through each of them cid = $(this).prop('id'); var nrow = cid.match('\\d+'); //find the row number var ckDpt = $('#' + $gvid + ' input[id*="ckDpt_' + nrow + '"]:checkbox'); //select the appropriate checkbox if ($(ckDpt).prop('checked') == true) {// if the checkbox is selected var a = $('#contentMain_cklistHR_gvCKList_txtCompletedBy_' + nrow); if (a.val() == "") { alert('Please enter your name to proceed'); //more to come... } } }); }\[/code\]}The problem is when I type something, the alert message box still pops up. The only time the alert don't pops up is when the textbox displays text from the server (.i.e. when the page loads).Is there any reason for that?EDITThis HTML is from the browser:\[code\]<input name="_ctl0:contentMain:cklistIT:gvCKList:_ctl2:txtCompletedBy" type="text" id="contentMain_cklistIT_gvCKList_txtCompletedBy_0" />\[/code\]They are all the same except that the last character is 0, 1, .. to 5
 
Back
Top