Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改无线基站上的txtbox长度更改ASP.NET和JavaScript_Javascript_Asp.net - Fatal编程技术网

更改无线基站上的txtbox长度更改ASP.NET和JavaScript

更改无线基站上的txtbox长度更改ASP.NET和JavaScript,javascript,asp.net,Javascript,Asp.net,我有以下代码: <asp:RadioButtonList ID="rdoCardType" runat="server" onchange="ValidateCCN();" AutoPostBack="false" Width="190px"> <asp:ListItem Value="Visa"> <img src="images/visa.gif" /> Visa</asp:ListItem> <asp

我有以下代码:

<asp:RadioButtonList ID="rdoCardType" runat="server" onchange="ValidateCCN();" AutoPostBack="false" Width="190px">
     <asp:ListItem Value="Visa">
        <img src="images/visa.gif" /> Visa</asp:ListItem>
     <asp:ListItem Value="MC">
        <img src="images/mm.gif" /> Master Card</asp:ListItem>
     <asp:ListItem Value="AE">
        <img src="images/ae.gif" /> American Express</asp:ListItem>
     <asp:ListItem Value="DC">
        <img src="images/dc.gif" /> Discover</asp:ListItem>
</asp:RadioButtonList>

签证
万事达卡
美国运通
发现
JavaScript是:

function ValidateCCN() {
        var y = document.getElementById('ctl00_site_body_txtCscNr');
        var x = document.getElementsByName('ctl00$site_body$rdoCardType');
        for (var i = 0; i < x.length; i++) {
            if (x[i].checked) {
                if (x.value == "AE")
                    y.maxLength = '3';
                break;
            }
        }
    }
函数validatedeccn(){
变量y=document.getElementById('ctl00_site_body_txtcsnr');
var x=document.getElementsByName('ctl00$site_body$rdoCardType');
对于(变量i=0;i

我错过了什么?因为文本框的长度没有改变。谢谢

它应该是x[i]。值-

function ValidateCCN() {
    var y = document.getElementById('ctl00_site_body_txtCscNr');
    var x = document.getElementsByName('ctl00$site_body$rdoCardType');
    for (var i = 0; i < x.length; i++) {
        if (x[i].checked) {
            if (x[i].value == "AE")
                y.maxLength = '3';
            break;
        }
    }
}
函数validatedeccn(){
变量y=document.getElementById('ctl00_site_body_txtcsnr');
var x=document.getElementsByName('ctl00$site_body$rdoCardType');
对于(变量i=0;i
不要使用最终名称或id来获取dom元素。尝试
document.getElementById(“”)