I had a scenario:
My MVCGrid View Image:
This my Html Javascript Code:
$('#btn_preview_').click(function(){
Validate()
});
function Validate()
{
$('.mvcGrid table tr').each(function () {
if($('.mvcGrid table tr input[name=MyCheckbox]:checkbox').is(':checked')==true)
{
var getText = $.trim($('.mvcGrid table tr td:eq(2) input[name=textboxRemarks]').val());
alert('SID ' + $(this).find('td:eq(1)').text() + ' getText ' + getText);
}
else
{
Alert('Checkbox is unchecked');
}
});
}
Addtional html code:
<div class="mvcGrid rowMarginTop">
@Html.Grid(Model.myData).Columns(columns =>
{
columns.Add(a => a.isF).Encoded(false).Sanitized(false).RenderValueAs(a=>Html.CheckBox("MyCheckbox",a.isF)).Titled("");
columns.Add(a => a.SID).Titled("SID");
columns.Add(a => a.Remarks).Titled("Remarks").Encoded(false).Sanitized(false).RenderValueAs(a => Html.TextBox("textboxRemarks", a.Rem));
}).WithPaging(10).Sortable(true).Filterable()
</div>
All i need to do is to validate if checkbox is checked and the remarks is not empty.
This javascript code is working but my problem is even in SID 02
the remarks is showing instead of empty.
My Question is how to get the right value of each textbox row?
Any suggestion is pretty much appreciated.
Try this.