我试图使用yii添加验证码到我的联系表单,但验证有一些问题.
我的模特
class ContactForm extends CFormModel
{
public $verifyCode;
public function rules()
{
return array(
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'on'=>'captchaRequired'),
array('verifyCode', 'safe'),
);
}
}
Run Code Online (Sandbox Code Playgroud)
我控制器中的代码
public function filters()
{
return array(
'accessControl',
);
}
public function accessRules()
{
return array(
array( 'allow', //allow all users to perform advertise and index action
'actions' => array('advertise','index', 'captcha'),
'users' => array('*'),
),
);
}
public function actions() {
return array(
// captcha action renders the CAPTCHA image displayed on the contact page
'captcha' => …Run Code Online (Sandbox Code Playgroud) 我有这个代码
$(document).ready(function(){
var oldwidth= $(window).width();
$(window).resize(function(){
var nw= $(window).width();
//compare new and old width
});
});
Run Code Online (Sandbox Code Playgroud)
问题是旧宽度仅在加载文档期间设置,新宽度在每次调整大小时都会更改。我想在调整大小之前获取宽度,这样我就可以检查用户是否正在减小宽度或增加屏幕宽度。
foreach($items as $value)
{
if($value['item1']=='somestring')
{
// some PHP code...
}
}
Run Code Online (Sandbox Code Playgroud)
不应该$value引用$items数组中的每个值.他们是什么意思$value['item1']?这$items是多维数组还是什么意思?
如果我有一个HTML代码段
<div>
<ul style="display:block">
<li>A</li>
<li>B</li>
</ul>
<ul style="display:none">
<li></li>
<li></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
如何使用jQuery来查找no.div中的ul元素的css属性是display: none?我知道我可以使用,$('div').children('ul').length但这会返回所有ul元素