0

我有以下登录表单,其中有两个 HTML5 文本框,需要验证:

<div id="SignUpForm" class="loginContainer">
    <div style="width: 100%; height: 20px">
        <div class="triangle">
        </div>
    </div>
    <table class="loginForm" align="left">
        <tr>
            <td align="left" class="style1">
                <input id="txtCustEmailID" type="email" name="txtCustEmailID" placeholder="Enter Email ID"
                    required style="width: 195px" />
            </td>
            <td align="left">
                <asp:Button ID="btnCustLogin" runat="server" Text="Sign Up" OnClick="btnCustLogin_Click" />
            </td>
        </tr>
        <tr>
            <td align="left" class="style1">
                <input id="txtCustPwd" name="txtCustPwd" type="password" required placeholder="Enter Password"
                    style="width: 193px" />
            </td>
            <td align="left">
                <input id="btnCancel" type="button" value="Cancel" onclick="cancel('txtCustEmailID','txtCustPwd','SignUpForm')" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left" style="font-size: medium; color: #FFFFFF;">
                <a href="#RegOnSrchdialog" name="modal" style="color: #FFFFFF; font-weight: bold"
                    onclick="EnableRegFormTxt('txtCustEmailID','txtCustPwd','SignUpForm')">Register</a>

            </td>
        </tr>
    </table>
</div>

在单击锚标记“注册”时,我正在调用一个 javascript 函数EnableRegFormTxt,我使用它来禁用登录表单文本框,以便它们的验证也将被禁用,但是这个 js 不起作用,我无法做任何回发由于验证,在页面上。

js是:

function EnableRegFormTxt(i, j, k) {
document.getElementById("txtCustFName").disabled = false;
document.getElementById("txtCustLName").disabled = false;
document.getElementById("txtCustREmail").disabled = false;
document.getElementById("txtCustRPwd").disabled = false;
document.getElementById("txtCustRePwd").disabled = false;
document.getElementById("txtCustPh").disabled = false;
document.getElementById(i).disabled = true;
document.getElementById(j).disabled = true;
document.getElementById(k).style = "display:none";

}

请让我知道我错在哪里。谢谢。

4

2 回答 2

0

你可以试试这个:

   function DisableRegFormTxt(i, j, k) {
    document.getElementById("txtCustFName").setAttribute('readonly');
    document.getElementById("txtCustLName").setAttribute('readonly');
    document.getElementById("txtCustREmail").setAttribute('readonly');
    document.getElementById("txtCustRPwd").setAttribute('readonly');
    document.getElementById("txtCustRePwd").setAttribute('readonly');
    document.getElementById("txtCustPh").setAttribute('readonly');

    }

    function EnableRegFormTxt(i, j, k) {
    document.getElementById("txtCustFName").removeAttribute('readonly');
    document.getElementById("txtCustLName").removeAttribute('readonly');
    document.getElementById("txtCustREmail").removeAttribute('readonly');
    document.getElementById("txtCustRPwd").removeAttribute('readonly');
    document.getElementById("txtCustRePwd").removeAttribute('readonly');
    document.getElementById("txtCustPh").removeAttribute('readonly');

    }
于 2013-09-24T14:51:50.663 回答
0

希望这可以帮助:

function makeReadOnly()
        {
         document.getElementById("TextBox1").readonly=true;         
        }

在点击事件或您想要的任何其他事件上调用上述函数。

这是您的功能:

function EnableRegFormTxt(i, j, k) {
document.getElementById("txtCustFName").readonly = false;
document.getElementById("txtCustLName").readonly = false;
document.getElementById("txtCustREmail").readonly = false;
document.getElementById("txtCustRPwd").readonly = false;
document.getElementById("txtCustRePwd").readonly = false;
document.getElementById("txtCustPh").readonly = false;
document.getElementById(i).readonly = true;
document.getElementById(j).readonly = true;
document.getElementById(k).style = "display:none";
}
于 2013-06-20T07:58:44.403 回答