0
我用下面的例子 http://jsfiddle.net/nc6NW/1/CakePHP的2.X禁用/啓用語法
然而,當我將其更改爲表單助手語法Jquery的不會重新啓用已禁用的保存功能。怎樣才能去掉給這個函數
<div id="newArticleForm">
<?php
echo $this->Form->create('Post', array('action' => 'add'));
echo $this->Form->input('article_title',array('type' => 'text', 'id'=>'ArticleHeader','div'=>false,'label'=>false,'class'=>'centertext',"placeholder"=>"Article Header"));
echo $this->Html->para(null,'<br>', array());
echo $this->Form->input('article_link',array('type' => 'text', 'id'=>'ArticleLink','div'=>false,'label'=>false,'class'=>'centertext',"placeholder"=>"Article Link"));
echo $this->Html->para(null,'<br>', array());
echo $this->Form->button('Cancel', array('type' => 'reset'), array('inline' => false));
echo $this->Form->button('Save', array('type' => 'submit', 'disabled'=>true), array('inline' => false));
echo $this->Form->end();
?>
</div>
<script>
$(':text').keyup(function() {
if($('#ArticleHeader').val() != "" && $('#ArticleLink').val() != "") {
$('#submit').removeAttr('disabled');
} else {
$('#submit').attr('disabled', true);
}
});
</script>