在Javascript中如何对DataGrid模板列中TextBox的值进行判断?
我想在Javascript中判断DataGrid模板列中TextBox的值是否为数字,应该怎么写?
HTML代码如下:
<asp:TemplateColumn HeaderText= "收款金额 ">
<HeaderTemplate>
<FONT face= "宋体 ">
<asp:Label id= "Label1 " runat= "server " Width= "136px "> 收款金额 </asp:Label> </FONT>
</HeaderTemplate>
<ItemTemplate>
<FONT face= "宋体 ">
<asp:TextBox id= "SKJE " runat= "server " ReadOnly= "True " onblur= "SK(); "> </asp:TextBox> </FONT>
</ItemTemplate>
<EditItemTemplate>
<FONT face= "宋体 "> </FONT>
</EditItemTemplate>
<HeaderStyle Width= "12% "> </HeaderStyle>
</asp:TemplateColumn>
在脚本中如何取得文本框的值?谢谢!!
------解决方案--------------------document.getElementById( "datagird1 ").rows[索引].cells[索引].children[索引].value
------解决方案--------------------document.getElementById( "datagird1_SKJE ").value
------解决方案-------------------- <asp:TextBox id= "SKJE " runat= "server " ReadOnly= "True " onblur= "SK(); "> </asp:TextBox>
改成
<input type= "text " runat= "server " id= "SKJE " />
然后再document.getElementById( "SKJE ").value
------解决方案--------------------onkeypress= "if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false; "
-------------------------------
在文本框的 onkeypress事件中加入以上代码,屏蔽键盘事件中,输入值不是数字则返回为false
------解决方案--------------------var Dg = document.getElementById( 'DataGrid1 ');
for(i = 1;i < Dg.rows.length; i++)
{
if (Dg.rows[i].cells[0].getElementsByTagName( "INPUT ")[0].value==你要判断的东西)
{
}
}