繁体   English   中英

jquery.validate不适用于选择框

[英]jquery.validate not working for select box

我正在尝试为我的表单提供一个验证规则。.对每个字段,它都工作正常,但是对于选择框,效果却不佳,

<script type="text/javascript">
jQuery(document).ready(function() {

        jQuery('form#EnrollmentAccountHolderInformationForm').validate({
//           ignore: function(){
//              return $('form#EnrollmentAccountHolderInformationForm input:hidden, form#EnrollmentAccountHolderInformationForm select');
//           },
             debug: false,
            rules: {
                "data[Enrollment][personalinfo_source]": {
                required:true
                },
                "data[Enrollment][person_last_name]": {
                required:true
                }
          }
    });

这是我的选择框名称;-数据[注册] [personalinfo_source]

这是选择框的代码:-

<h4 style="line-height:17px;">How did you hear <br/>about us?*</h4> 
                            <?php $options = array(
                                'Event Sponsorship' => 'Event Sponsorship',
                                'Internet'=>'Internet',
                                'Newspaper' => 'Newspaper',
                                'Outdoor Advertising' =>'Outdoor Advertising',
                                'Radio' => 'Radio',
                                'Telemarketing' => 'Telemarketing',
                                'Television' => 'Television',
                                'Social Media' =>'Social Media',
                                'Other'=>'Other');
                                 echo $this->Form->input('personalinfo_source',array('label'=>false,'id'=>'select','class' => "selectbox",'div'=>false,'options'=>$options, 'tabindex' => '16', 'empty' => 'Select','style' => "width:215px;"));
                            ?>
                            <div style="clear:both"> </div>

帮帮我。

您是否检查过HTML代码? 根据您的PHP代码(“ id” =>“选择”)。 选择框ID是“选择”而不是“ EnrollmentAccountHolderInformationForm”,我不确定...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM