如何获取所有的dropdownlist ID在jQuery中,是否选择了所有dropdownlist值或什么? [英] how to get all dropdownlist id in jquery whether all dropdownlist value selected or what?

查看:96
本文介绍了如何获取所有的dropdownlist ID在jQuery中,是否选择了所有dropdownlist值或什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Module
            <asp:Label ID="lbl_Name1" runat="server" ForeColor="Red" Text="*"></asp:Label>
            </td><td><asp:TextBox  ID="txtmodule" runat="server"  Width="193px" class="required" ></asp:TextBox></td></tr>

        Parameter Type
            <asp:Label ID="lbl_Name2" runat="server" ForeColor="Red" Text="*"></asp:Label>
            </td><td><asp:TextBox ID="txtparameterType" runat="server"

            Width="193px" class="required"></asp:TextBox></td></tr>
        <tr><td>

   Parameter Value
            <asp:Label ID="lbl_Name3" runat="server" ForeColor="Red" Text="*"></asp:Label>
            </td><td><asp:TextBox ID="txtparameterValue" runat="server" TextMode="MultiLine"

                class="required"></asp:TextBox></td></tr>
                <tr>


               parameters
                </td>
                <td>
                    <asp:DropDownList ID="ddl_parvalues" runat="server">
                        <asp:ListItem Value="">--select--</asp:ListItem>
                        <asp:ListItem Value="parameter1">value1</asp:ListItem>
                        <asp:ListItem Value="parameter2">value2</asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>

                parametertype
                </td>
                <td>
                    <asp:DropDownList ID="ddl_parmtype" runat="server">
                        <asp:ListItem Value="">--select--</asp:ListItem>
                        <asp:ListItem Value="type1">ParamType1</asp:ListItem>
                        <asp:ListItem Value="type2">ParamType1</asp:ListItem>
                    </asp:DropDownList>
                </td>
                </tr>

here i am using 2 dropdownlist,but in my proj we are using more than 5 dropdownlist and even 
declare every dropdownlist id into jquery is littelbit tuf job,please help me




and this is jquery with class


<pre lang="xml">&lt;script type=&quot;text/javascript&quot;&gt;
       $(document).ready(function() {
       $(&#39;#&#39; + &#39;&lt;%= btnSave.ClientID %&gt;&#39;).click(function(e) {
               var isValid = true;
               $(&quot;&#39;input[type=&#39;text&#39;].required&#39;, &#39;input[type=&#39;textarea&#39;].required&#39;&quot;).each(function() {
                   if ($.trim($(this).val()) == &#39;&#39;) {
                       isValid = false;
                       $(this).css({
                           &quot;border&quot;: &quot;1px solid red&quot;,
//                           &quot;background&quot;: &quot;#FFCECE&quot;

                       });
                   }
                   else {
                       $(this).css({
                           &quot;border&quot;: &quot;&quot;,
                           &quot;background&quot;: &quot;&quot;
                       });
                   }
               });
               if (isValid == false)
                   e.preventDefault();
               else
                   alert(&#39;Thank you for submitting&#39;);
           });
       });

   &lt;/script&gt;</pre>

here i am going display red colour border line when user going to save button without fill any textbox and multiline textbox field,,but this jquery is working for textbox and multiline textbox but its not working when usernot select any value from dropdownlist so,,please help me
  How Get selected value of dropdownlist   in jquery,and here i am taking value of textbox and textarea, but i dont know how to get selected value of drop downlist in jquery

推荐答案

(文档).ready(function(){
(document).ready(function() {


(&#39;#&#39; +&#39;& lt;%= btnSave.ClientID%&#39;).click(function(e){ var isValid = true;
(&#39;#&#39; + &#39;&lt;%= btnSave.ClientID %&gt;&#39;).click(function(e) { var isValid = true;


(&#39; input [type =&#39; text&#39;].required&#39;,& #39; input [type =&#39; textarea&#39;].required'& quot;).each(function(){ 如果(
(&quot;&#39;input[type=&#39;text&#39;].required&#39;, &#39;input[type=&#39;textarea&#39;].required&#39;&quot;).each(function() { if (


这篇关于如何获取所有的dropdownlist ID在jQuery中,是否选择了所有dropdownlist值或什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆