Yii 如何在我有基于jqrelcopy的其他表字段的master中添加Ajax验证?

Yii 如何在我有基于jqrelcopy的其他表字段的master中添加Ajax验证?,yii,yii-extensions,Yii,Yii Extensions,在母版页(_表单)中,我要保存三个字段 下降 文本框 选项列表,如果选择了选项列表中的某个选项,我需要一个JQrelcopy来显示,用户可以添加很多 使用JQrelcopy的值。存储在JQrelcopy中的值 要保存在其他表中 现在的问题是,我想像字段一样进行AJAX验证 不能为空,只允许输入字母字符 通过JQrelcopy插入的字段。我想创造一个 一个场景,但我不能正确理解 如何附加文件?有什么选择吗?只要把你的代码复制到问题上,(编辑它)。使用正确的格式,阅读。格式良好的问题更容易阅读,

在母版页(_表单)中,我要保存三个字段

  • 下降
  • 文本框
  • 选项列表,如果选择了选项列表中的某个选项,我需要一个JQrelcopy来显示,用户可以添加很多 使用JQrelcopy的值。存储在JQrelcopy中的值 要保存在其他表中

    现在的问题是,我想像字段一样进行AJAX验证 不能为空,只允许输入字母字符 通过JQrelcopy插入的字段。我想创造一个 一个场景,但我不能正确理解

  • 
    
    如何附加文件?有什么选择吗?只要把你的代码复制到问题上,(编辑它)。使用正确的格式,阅读。格式良好的问题更容易阅读,更容易理解,给你更快的答案。我尽了最大努力编辑了代码,很抱歉耽搁了,(谢谢bool.dev)好吧,这样更好,但有一件事,你不需要把问题本身放在blockquote中,即使用
    。这里的一般惯例是引用某些资源时使用
    ,例如引用某些文档。当然,你可以随心所欲。我将查看编辑,并尝试及时回答。
    <?php $form=$this->beginWidget('CActiveForm', array(  
    'id'=>'symptom-form',  
    'enableAjaxValidation'=>false,  
      'enableClientValidation'=>true,  
    
    <?php echo $form->errorSummary($model,"Please fill up the required field in red","");?>  
    <div class="row">  
        <div class="floatleft"><?php echo $form->labelEx($model,'body_system_id',   array ('id'=>'label_body_system', 'class'=>'label_name')); ?>  </div>
        <div class="floatright"><?php echo $form->dropDownList($model, 'body_system_id',    CHtml::listData(SystemMaster::model()->findAll("status != 'R'"),
                                        'id', 'system_name'),array('prompt' => ' ------------- Select ------------')); ?>  </div> 
        <?php echo $form->error($model,'body_system_id'); ?>
    </div>
    
    
    <div class="row">
        <div class="floatleft"><?php echo $form->labelEx($model,'symptom', array ('id'=>'label_symptom', 'class'=>'label_name')); ?></div>
        <div class="floatright"><?php echo $form->textField($model,'symptom',array('rows'=>6, 'cols'=>50)); ?></div>
        <?php echo $form->error($model,'symptom'); ?>
    </div>
    
    <div class="row">
        <div class="floatleft"><?php echo $form->labelEx($model,'symptom_type', array ('id'=>'symptom_type', 'class'=>'label_name')); ?></div>
        <div class="floatright"><?php echo $form->radioButtonList($model,'symptom_type',array('T'=>'TextBox','A'=>'TextArea', 'D'=>'DropDown', 'C'=>'CheckBox'), array("id"=>"r_list")); ?></div>
        <?php echo $form->error($model,'symptom_type'); ?>
    </div>
    
    <div class="form" id="symptom_value">
            <?php 
                $this->widget('ext.jqrelcopy.JQRelcopy',array(
    
                //the id of the 'Copy' link in the view, see below.
                'id' => 'copylink',
    
                //add a icon image tag instead of the text
                //leave empty to disable removing
                'removeText' => '<img src="images/delete.png" /><small>Delete</small>',
    
                //htmlOptions of the remove link
    
    
     'removeHtmlOptions' => array('style'=>'color:red;float:left;position:absolute;'),
    
                //options of the plugin, see http://www.andresvidal.com/labs/relcopy.html
                'options' => array(
    
                    //A class to attach to each copy
                    'copyClass'=>'newcopy',
    
                    // The number of allowed copies. Default: 0 is unlimited
                    'limit'=>0,
    
                    //Option to clear each copies text input fields or textarea
                    'clearInputs'=>true,
    
                    //A jQuery selector used to exclude an element and its children
                    //'excludeSelector'=>'.skipcopy',
    
                    //Additional HTML to attach at the end of each copy.
                            //'append'=>CHtml::tag('span',array('class'=>'hint'),'You can remove this line'),
                    'append'=>CHtml::tag('span',array('class'=>'hint'),''),
                )
                ))
            ?>
    
        <!-- ---------------The given codes are used to display Symptom Values if already exists ---------------->
    
        <div class="topHeading" id="sli_title" ><span class="label_name">Symptom Values</span></div>
    
         <?php 
            if (count($symptom)>0 & $flag == 'update')
            {
                ?>
                <?php
                for ($i=0; $i<count($symptom); $i++)
                {
                    ?>
                  <div class="row copy">
    
                                <?php
                                echo CHtml::Textfield('symptom_value[]', $symptom[$i] ,array('class'=>'skipcopy','style'=>'float:left; width:150px; margin-right:5px;'));?>
    
                                <?php if ($i>0)
                                {
                                    ?>
                                    <a href="#" onclick="$(this).parent().remove(); return false;" style="color: red;"><img src="images/delete.png"  align="" /><small>Delete</small></a>
                                                                    <span class="hint"></span>
    
                                <?php 
                                } 
    
                                ?>
    
                 </div> <?php  
                }
                ?>   
                <?php
            }
            else
            {
            ?>            
                            <div class="row copy">
                                <?php $i=0;
                                echo CHtml::Textfield('symptom_value[]', " " ,array('class'=>'skipcopy'));?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <?php //echo $form->dropDownList($model, 'body_system_id', CHtml::listData(SystemMaster::model()->findAll("status != 'R'"),
                                      //'id', 'system_name'),array('prompt' => ' ------------- Select ------------')); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <?php if ($i>0)
                            {
                                ?>
                                <div class="floatright"><a href="#" onclick="$(this).parent().remove(); return false;" style="color: red;"><img src="images/delete.png"  align="" /><small>Delete</small></a>
                                                                <span class="hint"></span>
                                                                </div>
                            <?php 
                            } $i++;
    
                            ?>
    
    
                            </div>
                <?php
            }
             ?>
                <div class="row"><div><a id="copylink" href="#" rel=".copy"> <img src="images/add.png" align="" /><small>Add Another</small></a></div></div>
    
                    </div>
    
            <!-- Symptom Values -->
                <div class="row buttons">
        <div class="floatright"><?php //echo CHtml::submitButton($model->isNewRecord ? 'Save' : 'Save', array ('onClick'=>'validate()')); ?></div>
                <div class="floatright"><?php echo CHtml::submitButton($model->isNewRecord ? 'Save' : 'Save'); ?></div>
    </div>
        <div class="floatright"><?php //echo CHtml::hiddenfield('Sys_val',' ' ,array ('id'=>'Sys_val')); ?></div>
    
    <?php $this->endWidget(); ?>
    </div><!-- form -->
    <script>
    $(document).ready(function() {
        check();
    
        function check()
        {
    
                if ($("#Symptom_symptom_type_2").prop('checked') || ($("#Symptom_symptom_type_3").prop('checked')))
                {
                    $("#symptom_value").show()
                }
                else 
                {
                    $("#symptom_value").hide()
                }
        }
    
    });
    if ($("#Symptom_symptom_type_2").click(function()
    {
        $("#symptom_value").show()
    }));
    
    if ($("#Symptom_symptom_type_3").click(function()
    {
        $("#symptom_value").show()
    }));
    
    if ($("#Symptom_symptom_type_1").click(function()
    {
        $("#symptom_value").hide()
    }));
    
    if ($("#Symptom_symptom_type_0").click(function()
    {
        $("#symptom_value").hide()
    }));
    function validate()
       {
       var body_system = document.getElementById("Symptom_body_system_id").value
       var symptom = document.getElementById("Symptom_symptom").value
    
    
       if ($("#Symptom_symptom_type_0").attr("checked") != "checked" 
          && $("#Symptom_symptom_type_1").attr("checked") != "checked" 
          && $("#Symptom_symptom_type_2").attr("checked") != "checked" 
          && $("#Symptom_symptom_type_3").attr("checked") != "checked"
          || (body_system == "" || symptom == ""))
       {
            alert("Please enter all the mandatory fields Body System , Symptom  and Symptom Type");
       }
       return;
       }
    </script>