• <tfoot id='5WMsv'></tfoot>

    <small id='5WMsv'></small><noframes id='5WMsv'>

    <legend id='5WMsv'><style id='5WMsv'><dir id='5WMsv'><q id='5WMsv'></q></dir></style></legend>
      <i id='5WMsv'><tr id='5WMsv'><dt id='5WMsv'><q id='5WMsv'><span id='5WMsv'><b id='5WMsv'><form id='5WMsv'><ins id='5WMsv'></ins><ul id='5WMsv'></ul><sub id='5WMsv'></sub></form><legend id='5WMsv'></legend><bdo id='5WMsv'><pre id='5WMsv'><center id='5WMsv'></center></pre></bdo></b><th id='5WMsv'></th></span></q></dt></tr></i><div id='5WMsv'><tfoot id='5WMsv'></tfoot><dl id='5WMsv'><fieldset id='5WMsv'></fieldset></dl></div>

          <bdo id='5WMsv'></bdo><ul id='5WMsv'></ul>

      1. 嗯.如何添加css“错误"在表单提交上输入的类?

        Yii. How to add css quot;errorquot; class to input on form submit?(嗯.如何添加css“错误在表单提交上输入的类?)
        • <small id='ymzKJ'></small><noframes id='ymzKJ'>

          <tfoot id='ymzKJ'></tfoot>
          • <bdo id='ymzKJ'></bdo><ul id='ymzKJ'></ul>
            <legend id='ymzKJ'><style id='ymzKJ'><dir id='ymzKJ'><q id='ymzKJ'></q></dir></style></legend>

              <tbody id='ymzKJ'></tbody>
          • <i id='ymzKJ'><tr id='ymzKJ'><dt id='ymzKJ'><q id='ymzKJ'><span id='ymzKJ'><b id='ymzKJ'><form id='ymzKJ'><ins id='ymzKJ'></ins><ul id='ymzKJ'></ul><sub id='ymzKJ'></sub></form><legend id='ymzKJ'></legend><bdo id='ymzKJ'><pre id='ymzKJ'><center id='ymzKJ'></center></pre></bdo></b><th id='ymzKJ'></th></span></q></dt></tr></i><div id='ymzKJ'><tfoot id='ymzKJ'></tfoot><dl id='ymzKJ'><fieldset id='ymzKJ'></fieldset></dl></div>
                  本文介绍了嗯.如何添加css“错误"在表单提交上输入的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 Yii 表格.某些字段是必需的.提交表单时,我需要将 CSS 类错误"添加到文本输入中.我的代码:

                  I have Yii form. Some fields are required. When form is submitted i need that CSS class "error" would be added to the text input. My Code:

                            <?php $form=$this->beginWidget('CActiveForm', array(
                                      'id'=>'contact-form',
                                      'enableClientValidation'=>true,
                                      'clientOptions'=>array(
                                              'validateOnSubmit'=>true,
                                      ),
                              )); ?>
                             <ul class="contact_form">
                                 <li class="row">
                                     <?php echo $form->labelEx($model,'name'); ?>
                                     <?php echo $form->textField($model,'name', array('class'=>'input')); ?>
                                     <?php echo $form->error($model,'name'); ?>
                                 </li>
                  ...
                  

                  现在我只收到带有错误消息的 div:

                  Now i just get div with error message:

                  <div class="errorMessage" id="ContactForm_name_em_" style="">Laukelis Vardas, pavard" negali būti tuias.</div>
                  

                  如何将错误"类添加到输入字段?

                  How to add "error" class to input field?

                  推荐答案

                  要同时进行 AJAX 验证,您应该或多或少地添加如下内容:

                  To have AJAX validation also, you should add something more or less like this:

                  <?php $form=$this->beginWidget('CActiveForm', array(
                            'id'=>'contact-form',
                            'enableClientValidation'=>true,
                            'clientOptions'=>array(
                                'validateOnSubmit'=>true,
                                'afterValidate' => 'js:function(form, data, hasError) { 
                                    if(hasError) {
                                        for(var i in data) $("#"+i).addClass("error_input");
                                        return false;
                                    }
                                    else {
                                        form.children().removeClass("error_input");
                                        return true;
                                    }
                                }',
                                'afterValidateAttribute' => 'js:function(form, attribute, data, hasError) {
                                    if(hasError) $("#"+attribute.id).addClass("error_input");
                                        else $("#"+attribute.id).removeClass("error_input"); 
                                }'
                            ),
                          )); ?>
                  

                  这篇关于嗯.如何添加css“错误"在表单提交上输入的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  <small id='J3gaN'></small><noframes id='J3gaN'>

                    <tbody id='J3gaN'></tbody>

                    <legend id='J3gaN'><style id='J3gaN'><dir id='J3gaN'><q id='J3gaN'></q></dir></style></legend>
                    <i id='J3gaN'><tr id='J3gaN'><dt id='J3gaN'><q id='J3gaN'><span id='J3gaN'><b id='J3gaN'><form id='J3gaN'><ins id='J3gaN'></ins><ul id='J3gaN'></ul><sub id='J3gaN'></sub></form><legend id='J3gaN'></legend><bdo id='J3gaN'><pre id='J3gaN'><center id='J3gaN'></center></pre></bdo></b><th id='J3gaN'></th></span></q></dt></tr></i><div id='J3gaN'><tfoot id='J3gaN'></tfoot><dl id='J3gaN'><fieldset id='J3gaN'></fieldset></dl></div>
                      <bdo id='J3gaN'></bdo><ul id='J3gaN'></ul>
                      <tfoot id='J3gaN'></tfoot>