checkbox, radio button validator

6 五月, 2009 at 5:03 下午 發表留言

我竟然漏左post 呢個咁important 既post, 就係checkbox, radio button 既validator:

貼係header 度~~再用customer validator 就得~~ very easy and useful ~~ excellent !!! ^^

<script type="text/javascript">
//– To Validate CheckBoxList
function ChequarSelecciondeTipoModificacion(source, args)
{
var chkListaTipoModificaciones= document.getElementById (‘<%= rbGift.ClientID %>’);
var chkLista= chkListaTipoModificaciones.getElementsByTagName(“input");
for(var i=0;i<chkLista.length;i++)
{
if(chkLista[i].checked)
{
args.IsValid = true;return;
}
}
args.IsValid = false;
}
</script>

+++++++++++++++++++++++++++++++++++++++++

<asp:RadioButtonList ID="rbGift" runat="server">
                                    <asp:ListItem Value="手機">手機</asp:ListItem>
                                    <asp:ListItem Value="短褲">短褲</asp:ListItem>
                                </asp:RadioButtonList>
                                        </td>
                                        <td>
                                <asp:CustomValidator ID="cv1″ runat="server" ErrorMessage="必須選擇一項"
                                                ClientValidationFunction="ChequarSelecciondeTipoModificacion" Font-Size="Small"></asp:CustomValidator>

Entry filed under: Uncategorized. Tags: , , .

只可輸入數字,+或-符號 RegularExpressionValidator Pass parameter from html to ASP.NET

發表留言

Trackback this post  |  Subscribe to the comments via RSS Feed