Ramco Ramco

Ramco Ramco

  • 422
  • 3.4k
  • 500k

Cursor on first TextBox

Sep 6 2024 10:40 AM

Hi

  I have below code . When alert is uncommented the focus is on first column otherwise no.

<script type="text/javascript">
        window.onload = function () {
            /*alert("hi");*/
            var empCodeField = document.getElementById("<%= txtEmployeeCode.ClientID %>");
            empCodeField.focus();
        };
    </script>

***********************
                                        <div class="col-lg-3 col-md-6 col-sm-12">
                                            <div class="form-group">
                                                <label>Code</label>&nbsp;<span style="color: red">*</span>
                                                <asp:TextBox ID="txtEmployeeCode" TabIndex="1" MinLength="2" MaxLength="10" class="form-control alpha" placeholder="Employee Code" required="true" runat="server"></asp:TextBox>
                                            </div>
                                        </div>

Thanks


Answers (5)