English 中文(简体)
jquery:我如何在本文本中为检查箱和电台添加验证?
原标题:jquery: How do I add validation for check-boxes and radios in this Script?
  • 时间:2012-05-13 03:33:43
  •  标签:
  • jquery

我正在为需要某种特别认证代码的客户进行一项评估。 我很接近,但我被困在我的check Boxesradio but。 我正在使用以下代码在可见领域寻找和过滤所需的领域。

虽然我可以包括我的投入:在同一支部发现/过滤器中,检查和收音箱的鉴定工作没有达到[回程(现值)=“”]。

我怎么能够包括/打上没有经过检查/选择的搜索/打字,但需要检查箱和无线电塔顿田? [ Note/strong>:the third document. 准备就绪,是我工作时的]

<>strong>my jquery>

<script type="text/javascript">
            $(document).ready(function() {
                $( fieldset#section-11,fieldset#section-12,fieldset#section-13 ).hide(); 
            });//end of close all fieldsets


            $(document).ready(function() {
                var projType = new Array(
                        {value :  Cars , sect_id :  fieldset#section-11 },
                        {value :  Planes , sect_id :  fieldset#section-12 },
                        {value :  Boats , sect_id :  fieldset#section-13 }
                    ); //end of projType array

            $("select#1169").on( change ,function () {
                var dropDownVal = $(this).val();
                var sect_id ="";
                    $(projType).each(function() {
                        $(this.sect_id).hide(); //hide all section each time you run thru here
                            if(this.value == dropDownVal) 
                                {
                                    $(this.sect_id).show();
                                }
                    });
            });
            });
$(document).ready(function(){
    $("#btnCatchReqFlds").on( click , function(){
        $("#holdErrMsg").empty();
        var reqButEmpty = $( fieldset:visible ).find( input[type="text"][class*="-required"],textarea[class*="-required"],select[class*="-required"] ).filter(function() 
            {
                    return $.trim($(this).val()) === "";
            });
                    if(reqButEmpty.length>0)
                        {
                            reqButEmpty.each(function() {
                                $( #holdErrMsg ).append("Please fill in the " + this.name + "<br />"); 
                            });
                        }
                    return !reqButEmpty.length;
                });
        });

        </script>

My html>>

<form method="post" action="">
    <div id="holdErrMsg"></div>
    <fieldset id="mainSection" name="mainSection">
                <legend style="color:blue; font-weight:bold">Project Overview Section</legend>

                <table style="width: 100%">
                    <tr>
                        <td style="height: 33px; width: 178px;">Name</td>
                        <td style="height: 33px"><input  id="1125" name="1125" class="1125-required" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="height: 33px; width: 178px;">Email</td>
                        <td style="height: 33px"><input id="1026" name="1026" class="1026-required" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="width: 178px">Product Title</td>
                        <td><input  id="1089" name="1089" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="width: 178px">Product Type</td>
                        <td><select id="1169" name="1169">
                        <option value="">Select</option>
                        <option value="Cars">Cars</option>
                        <option value="Boats">Boats</option>
                        <option value="Planes">Planes</option>
                        </select></td>
                    </tr>
                                        <tr><td>
                                        <button id="btnCatchReqFlds" type="button" name="btn">Check Required Fields</button>
                                        </td></tr>
                                    </table>
            </fieldset>

            <fieldset id="section-11" name="section-11">
                <legend style="color:fuchsia; font-weight:bold">Car Details Section</legend>

                <table cellpadding="2" style="width: 100%">
                    <tr>
                        <td style="width: 334px; height: 35px"><label>Size:*</label></td>
                        <td style="height: 35px"><input id="1245" class="1245-required" name="1245" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="height: 35px; width: 334px">Color:*</td>
                        <td style="height: 35px">
                        <select id="1433" class="1433-required" name="1433">
                        <option value="">Select</option>
                        <option value="Orange">Orange</option>
                        <option value="Blank">Blank</option>
                        <option value="Green">Green</option>
            </select></td>
                    </tr>
                    <tr>
                        <td style="width: 334px">Description:</td>
                        <td>
                        <textarea id="1290" name="1290" class="1290-required" rows="2" style="width: 433px"></textarea></td>
                    </tr>
                </table>
                            </fieldset>

            <fieldset id="section-12" name="section-12">
                <legend style="color:fuchsia; font-weight:bold">Plane Details Section</legend>

                <table cellpadding="2" style="width: 100%">
                    <tr>
                        <td style="width: 334px; height: 35px"><label>Size:</label></td>
                        <td style="height: 35px"><input id="1245" name="1245" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="height: 35px; width: 334px">Color*:</td>
                        <td style="height: 35px">
                                                <input type="checkbox" name="1433[]" id="1433[]" value="Orange" class="1433[]-required"/>Orange
                                                <input type="checkbox" name="1433[]" id="1433[]" value="Blue" class="1433[]-required"/>Blue
                                                <input type="checkbox" name="1433[]" id="1433[]" value="Green" class="1433[]-required"/>Green
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 334px">Description:</td>
                        <td>
                        <textarea id="1290" name="1290" rows="2" style="width: 433px"></textarea></td>
                    </tr>
                </table>
                            </fieldset>
            <fieldset id="section-13" name="section-13">
                <legend style="color:fuchsia; font-weight:bold">Boat Details Section</legend>

                <table cellpadding="2" style="width: 100%">
                    <tr>
                        <td style="width: 334px; height: 35px"><label>Size:</label></td>
                        <td style="height: 35px"><input id="1245" name="1245" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="height: 35px; width: 334px">Color:*</td>
                        <td style="height: 35px">
                                                <input type="radio" name="1834[]" id="1834[]" value="None" class="valuetext" class="1834[]-required">None
                                                <input type="radio" name="1834[]" id="1834[]" value="All" class="valuetext" class="1834[]-required">All
                       </td>
                    </tr>
                    <tr>
                        <td style="width: 334px">Description:</td>
                        <td>
                        <textarea id="1290" name="1290" rows="2" style="width: 433px"></textarea></td>
                    </tr>
                </table>
                            </fieldset><br>
<fieldset id="section-1011" name="section-1011">
                <legend style="color:green; font-weight:bold">Misc Info Section</legend>

                <table cellpadding="2" style="width: 100%">
                    <tr>
                        <td style="width: 334px; height: 35px"><label>Size:</label></td>
                        <td style="height: 35px"><input id="1301" name="1301" type="text" /></td>
                    </tr>
                    <tr>
                        <td style="height: 35px; width: 334px">Color:</td>
                        <td style="height: 35px">
                        <select id="1302" name="1302">
                <option value="Orange">Orange</option>
                        <option value="Blank">Blank</option>
                        <option value="Green">Green</option>
            </select></td>
                    </tr>
                    <tr>
                        <td style="width: 334px">Description:</td>
                        <td>
                        <textarea id="1303" name="1303" class="1303-required" rows="2" style="width: 433px"></textarea></td>
                    </tr>
                </table>
                            </fieldset>


</form>​
        <?php
        // put your code here
        ?>
    </body>
</html>
问题回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签