JQuery验证为两个相同的字段提供单独的结果

时间:2014-06-04 12:49:35

标签: jquery

我正在使用JQuery来验证表单中的字段。现在的问题是它显示了两个不同字段的不同结果。但我使用的是相同的功能。这是我迄今为止所做的...

    <div class="row-fluid">

<div class="span12">

    <div class="box">

        <div class="title">

            <h4>
                <span>Add Tax</span>
            </h4>

        </div>
        <div class="content">

                <form action="<@ofbizUrl>saveTaxAuthRateProduct</@ofbizUrl>" class="form-horizontal" id="taxForm" name="taxForm" method="POST">

                  <input type="hidden" name="requireTaxIdForExemption" value="N" />
                  <input type="hidden" name="includeTaxInPrice" value="Y" />

                <div class="form-row row-fluid">
                    <div class="span12">
                        <div class="row-fluid">
                            <label class="form-label span4" for="taxAuthGeoId">Geo</label>
                            <div class="span3 controls sel">
                            <select class="nostyle required" name="taxAuthGeoId" id="taxAuthGeoId" >
                                <option value="">Select</option>

                                <#list authorityList as authGeo>
                                    <option value="${authGeo.taxAuthGeoId}">${authGeo.taxAuthGeoId}</option>
                                </#list>

                            </select>   
                        </div>
                    </div>
                </div>
            </div>

                <div class="form-row row-fluid">
                    <div class="span12">
                        <div class="row-fluid">
                            <label class="form-label span4" for="taxAuthPartyId">Party</label>
                            <div class="span2 controls sel">
                            <select class="nostyle required" name="taxAuthPartyId" id="taxAuthPartyId">
                                <option value="">Select</option>
                                <#list authorityList as authGeo>
                                    <option value="${authGeo.taxAuthPartyId}">${authGeo.taxAuthPartyId}</option>
                                </#list>
                            </select>   
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-row row-fluid">
                    <div class="span12">
                        <div class="row-fluid">
                            <label class="form-label span4" for="taxAuthorityRateTypeId">Rate Type</label>
                            <div class="span2 controls sel">
                            <select class="nostyle required" name="taxAuthorityRateTypeId" id="taxAuthorityRateTypeId">
                                <option value="">Select</option>
                                <#list rateTypeList as rateType>
                                    <option value="${rateType.taxAuthorityRateTypeId}">${rateType.description}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="form-row row-fluid">
                    <div class="span12">
                        <div class="row-fluid">
                            <label class="form-label span4" for="taxPercentage">Tax Percentage</label>
                            <input class="span2" id="taxPercentage" type="text" name="taxPercentage"/>
                        </div>
                    </div>
                </div> 

                <div class="form-row row-fluid">
                    <div class="span12">
                        <div class="row-fluid">
                            <div class="form-actions center">
                            <div class="span3"></div>
                            <div class="span4 controls">
                                <button type="submit" class="btn marginR10">Save</button>
                                <button  type="reset" class="btn btn-danger">Cancel</button>
                            </div>
                            </div>
                        </div>
                    </div> 
                </div>
            </form>

        </div>

    </div><!-- End .box -->

</div><!-- End .span12 -->

<script>    
$(document).ready(function() {  


$("#taxForm").validate({
    ignore: null,
    ignore: 'input[type="hidden"]',

    rules: {
        taxAuthGeoId: {
            required: true

        },
        taxAuthPartyId: {
            required: true

        },
        taxAuthorityRateTypeId:{
            required:true
        },
        taxPercentage:{
            required:true,
            number:true

        }

    },
    messages: {
        taxAuthGeoId: {
            required: "Please select Geo"

        },
        taxAuthPartyId: {
            required: "Please select PartyId"

        },
        taxAuthorityRateTypeId: {
            required: "Please select RateTypeId"

        }
    }   
     });
 });

   </script>    

taxAuthorityRateTypeId不起作用。请问有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

我在表单的任何地方都没有看到“taxAuthorityRateTypeId”字段。