18 Nov 2011

Loop through textboxes in gridview using javascript

<script language="javascript" type="text/javascript">
            function Loop() {
                var grid = document.getElementById("<%=GridView1.ClientID%>");
                var inputs = grid.getElementsByTagName("input");
                for (var i = 0; i < inputs.length; i++) {
                    if (inputs[i].type == "text") {
                        if (inputs[i].value == "") {
                            if (inputs[i].name.indexOf("txtName") != -1) {
                                alert("Please Enter Name");
                                inputs[i].focus();
                                return false;
                            }
                        }
                    }
                }
            }
</script>

No comments:

Post a Comment