2015-03-23 07:44
浏览 75


I'm new to yii..i create one form in that i want to include the validations so i create one external file if i include that i got this error in chrome..if i select inspect elements it shows the html page but i use only php file how to recover it.how to include the external js in php on yii.i use one method tell me is that right or wrong.

$baseUrl = Yii::app()->baseUrl; 
  $cs = Yii::app()->getClientScript();
/* @var $this SiteController */
/* @var $model LoginForm */
/* @var $form CActiveForm  */

$this->pageTitle=Yii::app()->name . ' - SimpleLogin';


<p>Please fill out the following form with your login credentials:</p>

<div class="form" onsubmit="check()">

echo CHtml::beginForm($url,'POST') ?>

    <p class="note">Fields with <span class="required">*</span> are required.</p>

    <div class="row",id="s">
        <?php echo CHtml::label('name',''); ?>
        <?php echo CHtml::textField('name','',array('onblur'=>"keyw()",'id'=>'s')); ?>

    <div class="row">
        <?php echo CHtml::label('password',''); ?>
        <?php echo CHtml::passwordField('password',''); ?>
    <div class="row">
        <?php echo CHtml::dropDownList('role','',
              array('M' => 'Male', 'F' => 'Female'),
              array('empty' => '(Select a gender)'));
    <div class="row buttons">
        <?php echo CHtml::submitButton('Submit',array('name'=>'submit')); ?>
<?php echo CHtml::encode($model->name)."-". CHtml::encode($model->password)."-".CHtml::encode($model->role);?>
<?php echo CHtml::endForm(); ?> 

</div><!-- form -->

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongzhang2150 2015-03-23 10:16

    As you said in the comments, you see check() is not defined error. This means The external javascript file(logincheck.js) isn't included properly. So, browser cant find check() function. Therefore, one possible problem is Path to js file. As a result $cs->registerScriptFile($baseUrl.'/js/logincheck.js') is the first possible problem. Another possibility: there are somethings wrong inside logincheck.js file, for example syntax errors. You can inspect the browser console errors for more information.

    解决 无用
    打赏 举报

相关推荐 更多相似问题