【发布时间】:2017-06-21 12:32:09
【问题描述】:
我的输入框使用占位符文本和 jquery 来确保在我添加文本(即不是占位符文本)之前它不会触发。我想用文本区域替换输入框,但无法让 jquery 工作。使用下面的文本区域,无论我是否在文本区域中输入,都会触发提交按钮。
<div class="RepForm-loggedin" >
<form name="RepForm" method="POST" action="<?php echo $this->newReply;?>">
<table name="RepFormTable" style="width:100%">
<tr>
<td style="width:100%">
//CURRENT INPUT BOX
<input type="text" rows="8" id="repContent" class="inputbox inputbox-title placeholder-soc-med" name="repContent" placeholder="Ask a question . . ."/>
//DESIRED REPLACEMENT TEXT AREA
<textarea type="text" rows="8" style="max-width:600px; width:100%" id="repContent" class="inputbox inputbox-title placeholder-soc-med" name="repContent" placeholder="Ask a question . . ."></textarea>
</td>
</tr>
<tr>
<td style = "text-align:right;">
<input type="submit" value="Submit" id="sendComment" class="dgrey-button">
</td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#sendComment').attr('disabled',true);
$('#repContent').keyup(function(){
if($(this).val().length !=0)
$('#sendComment').attr('disabled', false);
else
$('#sendComment').attr('disabled',true);
})
});
</script>
【问题讨论】:
标签: javascript php jquery textarea inputbox