duanbei1598 2015-06-15 09:08
浏览 124
已采纳

jQuery:chzn-select的验证消息位置

In a form of a web application I would like the message error validation to be showed under the select menu (in particular it is a chzn-select plugin menu). As you can see from this screenshot: enter image description here

it works for "Metodo Pagamento" select while it does not work for "Cliente" select and this because, I think, Cliente is a chzn-select menu. My boss wants me to move that message under the select. Here is some code from the php-html page generation file:

<style>

 label[for="oggetto[]"] {
 padding: 76px 0px 0px 143px !important;
 }

 label[for="modalita_pagamento"] {  
 padding: 13px 0px 0px 130px !important;
 }

 div.selector {
 overflow: visible;
 }

 #filed-sel {
 padding: 19px !important;
 }

</style>

...

<p>
  <label>Cliente</label>
  <span class="field" id="filed-sel">
     <?php
        if (isset($progetto['id_cliente']))
          $sistema->clienti->selectMenuClienti($progetto['id_cliente']);
        else
          $sistema->clienti->selectMenuClienti(null);
     ?>
  </span>
</p>

...

<p>
  <label>Metodo pagamento</label>
  <span class="field" id="filed-sel">
     <?php
        if (isset($progetto['metodo_pagamento']))
        $sistema->progetti>setPagamentoMetodo($progetto['metodo_pagamento']);
        else
        $sistema->progetti->setPagamentoMetodo(null);
    ?>
  </span>
</p> 

...

public function selectMenuClienti($id_cli) {
    $list_cli = $this->allClienti("");
    echo '<select data-placeholder="Scegli un cliente..." id="client_prj"  name="client_prj" class="chzn-select">';
    echo '<option value=""></option>';

    for($i=0; $i<count($list_cli); $i++) {
        if (($id_cli != null) && ($id_cli == $list_cli[$i]["id"])) {
            echo '<option value="'.$list_cli[$i]["id"].'"  selected>'.$list_cli[$i]["id"].' - '.$list_cli[$i]["cognome"].' '.$list_cli[$i]["nome"].'</option>';
        }
        else {echo '<option value="'.$list_cli[$i]["id"].'">'.$list_cli[$i]["id"].' - '.$list_cli[$i]["cognome"].' '.$list_cli[$i]["nome"].'</option>';
        }
    }

    echo '</select>';
}
  • 写回答

2条回答 默认 最新

  • duanlou2917 2015-06-15 09:16
    关注

    You can use the errorPlacement option to change the positioning of the error message

    errorPlacement: function (error, element) {
        //check whether chosen plugin is initialized for the element
        if (element.data().chosen) { //or if (element.next().hasClass('chosen-container')) {
            element.next().after(error);
        } else {
            element.after(error);
        }
    }
    

    Demo: Fiddle

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题