Tuesday, September 3, 2013

how to validate a text box in asp.net using javascript

<script language="javascript" type="text/javascript">
        function EmptyText() {
            if (document.getElementById("txtStaffNo").value == "") {
                alert("Please provide Staff ID");
                document.getElementById("txtStaffNo").focus();
                return false;
            }
        }
    </script>

Usgae:

<asp:Button ID="btnOk" runat="server" Text="OK" OnClientClick="return EmptyText();"/>

No comments:

Post a Comment