国家/地区下拉列表正在通过验证。但是州和城市不是

时间:2018-02-02 08:00:34

标签: php

我正在尝试验证国家,州和城市。但是国家正在得到验证,而城市和州则没有。

尝试了客户端和服务器端验证。请有人建议解决方案。

<?php
$options = array();
$options[''] = BLANK_SELECT;
if (count($countries)) {
    foreach ($countries as $val) {
        $options[$val->id] = $val->country;
    }
}

echo form_dropdown('pcountryid', $options, $paddress->countryid, 'id="pcountryid" class="select2 req col-md-6 form-control" style="width:380px;" required');
?>

.......

<?php
$options = array();
$options['-1'] = BLANK_SELECT;

if (count($states)) {
    foreach ($states as $val) {
        $options[$val->id] = $val->state;
    }
}

echo form_dropdown('pstateid', $options, $paddress->stateid, 'id="pstateid" class="select2 req col-md-6 form-control" style="width:380px;" required');
?>

......

<?php
$options = array();
$options['-1'] = BLANK_SELECT;
if (count($cities)) {
    foreach ($cities as $val) {
        $options[$val->id] = $val->city;
    }
}
echo form_dropdown('pcityid', $options, $paddress->cityid, 'id="pcityid" class="select2 req col-md-6 form-control" style="width:380px;" required');
?>

//服务器端验证: $ this-&gt; form_validation-&gt; set_rules(&#39; pcountryid&#39;,&#39; Country&#39;,&#39; required | is_natural&#39;); //为国家工作。 $ this-&gt; form_validation-&gt; set_rules(&#39; pcityid&#39;,&#39; City&#39;,&#39; required | is_natural&#39;); $ this-&gt; form_validation-&gt; set_rules(&#39; pstateid&#39;,&#39; State&#39;,&#39; required | is_natural&#39;);

//客户端验证: 价值&#34; -1&#34; $ options数组的第一个选项负责验证&#34; required&#34;在国家..

0 个答案:

没有答案