none
Validation of grid view for all rows using javascript RRS feed

  • Question

  • Hi,

    I have a gridview control and in that control i added textboxs and dropdown controls.I wanted to validate all rows of a gridview on button click like all text boxes and dropdown should be mandatory field.I used below script but it is working for only first row.Remaining rows it is not working.Please help me how to do this using javascript.below script iam using

        <script type="text/javascript">


        function check() {

            var grid = document.getElementById('<%= gvOtherEfforts.ClientID %>');
            if (grid != null) {
                var Inputs = grid.getElementsByTagName("input");
                for (i = 0; i < Inputs.length; i++)
                {

                    if (Inputs[i].type == 'text') {
                        if (Inputs[i].id == 'ctl00_m_g_1d8490ed_b366_492f_acf3_b52b4615beb7_ctl00_gvOabcde_ctl02_txttest1')
                        {
                            if (Inputs[i].value == "")
                            {
                                alert("Enter Taskid ");
                                return false;
                            }
                        }


    regards,




                        if (Inputs[i].id == 'ctl00_m_g_1d8490ed_b366_492f_acf3_b52b4615beb7_ctl00_gvxwzss_ctl02_txttest2') {
                            if (Inputs[i].value == "") {
                                alert("Please Enter Remarks ");
                                return false;
                            }
                        }


                    }
                }
            }
        }



    </script>

    Regards,

    Praveen

    Saturday, August 13, 2016 10:12 AM

Answers