0

这是我的 js 代码:

function validate_reg() {
    try {

        if (document.getElementById('txtFname').value == "") {
            alert("enter 2");
            document.getElementById('lblFnameError').style.color = "red";
            document.getElementById('lblFnameError').innerHTML = "Error : Enter First NameD.";
            document.getElementById('txtFname').focus();
            validate_reg_suc = false;
            return false;
        }
        validate_reg_suc = true;
        alert("done");
    } catch (exc) {
        alert("Error : " + exc);
        return false;
    }
}

我的 html :

<table style="width:100%;">

    <tr>
        <td style="width:200px;"></td>
        <td style="width:257px;">

        </td>
        <td>

        </td>
    </tr>

    <tr>
        <td style="width:200px;">Select AccSelect Account Type&nbsp;</td>
        <td style="width:257px;">
            <select runat="server" clientidmode="Static"  style="width:250px;" id="cmbAType">
                <option value="0">SELECT</option>
                <option value="REVIWER">REVIWER</option>
                <option value="CANDIDATE">CANDIDATE</option>
            </select>
        </td>
        <td>
            <label id="lblAtype" style="color:Red">Validation   </td>
    </tr>

    <tr>
        <td style="width:200px;">User Type</td>
        <td style="width:257px;">
            <select runat="server" clientidmode="Static"  style="width:250px;" id="cmbUtype">
                <option value="0">Select</option>
                <option value="Dr.">Dr.</option>
                <option value="Miss">Miss</option>
                <option value="Mr">Mr</option>
                <option value="Mrs">Mrs</option>
                <option value="Ms">Ms</option>
                <option value="Prof">Prof</option>
            </select>
        </td>
        <td>
            <label id="Label1" style="color:Red">Validation</label>
        </td>
    </tr>

    <tr>
        <td style="width:200px;">First Name</td>
        <td style="width:257px;">
            <input clientidmode="Static" runat="server" style="width:250px;" id="txtFname" type="text" />
        </td>
        <td>
            <label id="lblFnameError" style="color:Red">Validation</label>
        </td>
    </tr>

    <tr>
        <td style="width:200px;">Middle Name</td>
        <td style="width:257px;">
            <input runat="server" clientidmode="Static"  style="width:250px;" id="txtMname" type="text" />
        </td>
        <td>
            <label id="Label3" style="color:Red">Validation</label>
        </td>
    </tr>

    <tr>
        <td style="width:200px;">Last Name</td>
        <td style="width:257px;">
            <input runat="server" clientidmode="Static"  style="width:250px;" id="txtLname" type="text" />
        </td>
        <td>
            <label id="Label4" style="color:Red">Validation</label>
        </td>
    </tr>

    <tr>
        <td style="width:200px;">Degree</td>
        <td style="width:257px;">
            <input runat="server" clientidmode="Static"  style="width:250px;" id="Text4" type="text" />
        </td>
        <td>
            <label id="Label5" style="color:Red">Validation</label>
        </td>
    </tr>

    <tr>
        <td style="width:200px;">Email ID</td>
        <td style="width:257px;">
            <input runat="server" clientidmode="Static" style="width:250px;" id="Text5" type="text" />
        </td>
        <td>
            <label id="Label6" style="color:Red">Validation</label>
        </td>
    </tr>
    <tr>
        <td style="width:200px;"></td>
        <td style="width:257px;">
    <asp:Button ID="btnRegister" CausesValidation="true" OnClientClick="return validate_reg()" runat="server" Text="Register" 
                onclick="btnRegister_Click" />
    <input id="Reset1" type="reset" value="reset" />
</td>
<td>
    <label id="Label7" style="color:Green">Message</label>
</td>
</tr>
</table>

js在html之后调用,但仍然出现这个错误

4

0 回答 0