我Zend_Validate用来验证一些表单输入(Zend Framework版本是1.8.2).出于某种原因,使用此处Zend_Filter_Input描述的界面不起作用:
$data = $_POST;
$filters = array('*' => array('StringTrim'));
$validators = array('driverName' => array('NotEmpty','messages' => 'This should override the default message but does not!'));
$inputFilter = new Zend_Filter_Input($filters,$validators,$data);
$messages = $inputFilter->getMessages();
debug($messages); //show me the variable contents
Run Code Online (Sandbox Code Playgroud)
输出来自debug($messages):
Array
(
[driverName] => Array
(
[isEmpty] => You must give a non-empty value for field 'driverName'
)
)
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我都无法覆盖那条消息.如果我直接使用验证器,即:
$notEmpty = new Zend_Validate_NotEmpty();
$notEmpty->setMessage('This WILL override the default validation error message');
if (!$notEmpty->isValid($_POST['driverName'])) …Run Code Online (Sandbox Code Playgroud) 我的表单中有一个文本框数组.使用javascript函数动态添加文本框.文本框的名称如下:
account[0]_number account[0]_balance
account[1]_number account[1]_balance
Run Code Online (Sandbox Code Playgroud)
如何使用jquery获取这些文本框的值?
以下是我尝试的方法,但它给出了错误:
if($('#account[' + iteration + ']_balance').val().length==0)
Run Code Online (Sandbox Code Playgroud) 我想隐藏所有class ="csc-content",其中前一个兄弟是h4 class ="faq".
更新错误:我认为这是错误的......以前的兄弟姐妹不是h4.但我希望你明白,如果"问题"有"faq"/ UPDATE类,那么所有"答案"都将被隐藏
这是html:
<div id="centerCol-1">
<div id="c65" class="csc-default normal">
<div class="csc-header csc-header-n1"><h4 class="faq">FAQ question1</h4></div>
<div class="csc-content active"><p class="bodytext">Answer1</p></div>
</div>
<div id="c67" class="csc-default normal">
<div class="csc-header csc-header-n2"><h4 class="faq">FAQ question2</h4></div>
<div class="csc-content active"><p class="bodytext">Answer2</p></div>
</div>
<div id="c68" class="csc-default normal">
<div class="csc-header csc-header-n3"><h4>not FAQ</h4></div>
<div class="csc-content active"><p class="bodytext">Not an answer, just normal content</p></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery应该是这样的:
// find all outer divs with class csc-default in the div centerCol-1
// test if they contain a header div with an h4 …Run Code Online (Sandbox Code Playgroud) 在jquery中,我需要引用一个表单,更改动作URL,然后发布它.
所以我可以使用ID来获取我的表单:
$("#frmtest")
Run Code Online (Sandbox Code Playgroud)
现在我想更改动作网址,然后发布它.
我正在为婚礼摄影师构建订单,因此客人可以从他网站的客户专辑部分订购图片.
客人订购1到50张图片,所以我目前正在使用jQuery的clone()功能,这非常有用.
但是我还需要更改每个输入的名称attr,每次添加一个,以便表单处理可以获取新输入.
name="picture-1"
add field
name="picture-2"
Run Code Online (Sandbox Code Playgroud)
有谁知道这是否可能?
我相信我addClass()每次都可以使用clone()它,但我怎么能addClass()算数呢?
谢谢
我试图在JSON响应中发送一个函数,并试图在js中提醒该函数.下面是代码.
JS:
$('input').keyup(function(){
$.ajax({
type: "POST",
url: "sample.php",
dataType : 'json',
data: 'val='+$('input').val(),
success: function(response){
var json = transport.responseText.evalJSON();
alert(json.function()); // => **should alert 'foo bar' - but not**
}
});
});
Run Code Online (Sandbox Code Playgroud)
PHP:
<?php
// Our sample array
$foo = array(
'string' => 'bar',
'function'=> 'function(){return "foo bar";}'
);
$value_arr = array();
$replace_keys = array();
foreach($foo as $key => &$value){
// Look for values starting with 'function('
if(strpos($value, 'function(')===0){
// Store function string.
$value_arr[] = $value;
// Replace function string …Run Code Online (Sandbox Code Playgroud) 我相信rails.js是:remote => true在rails表单上工作所必需的,但我的public/javascripts文件夹中没有rails.js.我有:
application.js
jquery.js
jquery.min.js
jquery-ui.js
jquery-ui.min.js
jquery-ujs.js
jrails.js
Run Code Online (Sandbox Code Playgroud)
我如何获得rails.js?谢谢
Hy家伙,我怎样才能得到最后一个元素的"显示"?
我这样做:$('.slide').filter(':last').attr("display");但没有奏效.
我尝试过 $('.slide:last').attr("display");也没有用.
我究竟做错了什么?TKS!
我在jquery代码中有以下内容:
$(document).keypress(function (e) {
if (e.keyCode == 13) {
}
});
Run Code Online (Sandbox Code Playgroud)
我如何将其变成javascript所以我不需要加载jquery everyime?
我想从 Zend Framework 中的表字段中减去一个金额。我可以使用以下查询使用 SQL 运行它:
UPDATE `Person` SET credit=credit-50 where id=1
Run Code Online (Sandbox Code Playgroud)
但是如何在 Zend Framework 中编写上面的 SQL 查询呢?