<form:option value =“0”>验证无法使用jquery验证

时间:2015-09-16 13:07:31

标签: spring-mvc

我正在使用selected.js和jquery验证插件但是下面的代码不起作用,我没有得到任何错误。请帮助我如何使用jquery验证插件来验证这一点。

<form:form method="post" id="clienteditform" action="updateClient.htm" name="clienteditform" cssClass="form-horizontal" modelAttribute="eReg" role="form">
<div class="form-group">
        <label class="col-sm-2 control-label">Country</label>
            <div class="col-sm-10">
                <form:select cssClass="chosen-select" cssStyle="width:450px;" id="country" name="country" path="cusDTO.client.cl_country_id">
                <form:option value="0">Select country</form:option>
                <form:options items="${countryList}" itemValue="country_id" itemLabel="country_name"/>
                </form:select>

            </div>
</div>
</form>
<script type="text/javascript">

        $(document).ready(function(){

             $(".chosen-select").chosen();

             $.validator.addMethod("validateCountry", function(value, element) {
                return this.optional(element) || value != '0' ;
            }, " Please select country");

             $("#clienteditform").validate({
                 rules: {

                     "cusDTO.client.cl_country_id":{
                         validateCountry : true
                     }
                 }

             });

        });

0 个答案:

没有答案