drc15469 2015-03-23 07:44
浏览 76
已采纳

未捕获的SyntaxError:意外的令牌<在yii中

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.

<?php 
$baseUrl = Yii::app()->baseUrl; 
  $cs = Yii::app()->getClientScript();
  $cs->registerScriptFile($baseUrl.'/js/logincheck.js');
  ?>
<?php
/* @var $this SiteController */
/* @var $model LoginForm */
/* @var $form CActiveForm  */

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

<h1>Login</h1>



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

<div class="form" onsubmit="check()">
<?php 
 $url=Yii::app()->createAbsoluteUrl('site/newlogin');

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>

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

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

</div>
  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 根据以下文字信息,做EA模型图
  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥60 关机时蓝屏并显示KMODE_EXCEPTION_NOT_HANDLED,怎么修?
  • ¥66 如何制作支付宝扫码跳转到发红包界面