码迷,mamicode.com
首页 > 其他好文 > 详细

Yii 验证码验证

时间:2014-07-02 17:53:11      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   java   os   art   

控制器如下

bubuko.com,布布扣

LoginForm如下

bubuko.com,布布扣

视图如下

        <div class="loginbody">
            <span class="systemlogo"></span>
            <div class="loginbox">
                <ul>
                    <?php $form = $this->beginWidget(‘CActiveForm‘,array(‘method‘=>‘post‘))?>
                        <li class="loginuser"><?php echo $form->textField($loginForm,‘username‘,array(‘class‘=>‘loginuserinput‘,‘value‘=>‘user‘,‘onclick‘=>‘JavaScript:this.value=""‘,"size"=>"20"));?></li>
                        <li class="loginpwd"><?php echo $form->passwordField($loginForm,‘password‘,array(‘class‘=>‘loginuserinput‘,‘value‘=>‘‘,‘onclick‘=>‘JavaScript:this.value=""‘,"size"=>"20"));?></li>
                        <li class="code"><?php echo $form->textField($loginForm,‘captcha‘,array(‘class‘=>‘loginuserinput‘,‘value‘=>‘‘,‘onclick‘=>‘JavaScript:this.value=""‘,"size"=>"8"));?>
                        <div style="float:right;margin-right:64px;"><?php $this->widget(‘CCaptcha‘,array(‘showRefreshButton‘=>false,‘clickableImage‘=>true,‘imageOptions‘=>array(‘alt‘=>‘点击换图‘,‘title‘=>‘点击换图‘,‘style‘=>‘cursor:pointer‘))); ?></div></li>
                        <div class="clb"></div>
                        <li><input name="login" type="submit" class="loginbtn" value="登录" />&nbsp;&nbsp;&nbsp;&nbsp;<label><a href="#">忘记密码?</a></label></li>
                    <?php $this->endWidget();?>
                </ul>
            </div>
        </div>
    </body>
</html>
<script type="text/javascript">
$(function(){
    <?php if($form->error($loginForm,‘password‘)){echo "alert(‘".str_replace(‘<div class="errorMessage">‘,‘‘,str_replace(‘</div>‘,‘‘,$form->error($loginForm,‘password‘)))."‘);";}?>
    <?php if($form->error($loginForm,‘username‘)){echo "alert(‘".str_replace(‘<div class="errorMessage">‘,‘‘,str_replace(‘</div>‘,‘‘,$form->error($loginForm,‘username‘)))."‘);";}?>
    <?php if($form->error($loginForm,‘captcha‘)){echo "alert(‘".str_replace(‘<div class="errorMessage">‘,‘‘,str_replace(‘</div>‘,‘‘,$form->error($loginForm,‘captcha‘)))."‘);";}?>
});
</script> 

Yii 验证码验证,布布扣,bubuko.com

Yii 验证码验证

标签:des   style   http   java   os   art   

原文地址:http://www.cnblogs.com/uduemc/p/3819883.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!