Home > php教程 > php手册 > Yii表单验证中,提交前验证,不通过不提交

Yii表单验证中,提交前验证,不通过不提交

WBOY
Release: 2016-06-06 20:10:57
Original
897 people have browsed it

以前记得有这么一个写法,就是当表单中的内容不符合验证规则时,会不允许提交,时间一长忘了怎么写了,手册里面也没写,查了一下资料,做一下笔记 : $form = $this-beginWidget('CActiveForm',array( 'id' = 'add_host', 'enableAjaxValidation' = false, '

以前记得有这么一个写法,就是当表单中的内容不符合验证规则时,会不允许提交,时间一长忘了怎么写了,手册里面也没写,查了一下资料,做一下笔记 :

    $form = $this->beginWidget('CActiveForm',array(
            'id' => 'add_host',
            'enableAjaxValidation' => false,
            'enableClientValidation' => true,
            'clientOptions' => array(
                    'validateOnSubmit' => true  //在这个位置做验证
                ),
            'focus' => array($model,'ip')
        ));
    ?>
Copy after login

本文标题:Yii表单验证中,提交前验证,不通过不提交

本文链接:http://www.maben.com.cn/archives/593.html转载请注明出处

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template