所以基本上我想要的是禁用提交按钮,直到文本区域中达到某个字数。
我环顾四周并试图找到方法来做到这一点,但没有运气。
任何提示或帮助?
<form method="post" id="writearticle" action="submitarticle.php">
<script>
$('#writearticle').submit(function(event) {
var text = $("#content").val();
text = text.split(" ");
// check for at least 10 words
if(text.length < 10){
console.log("prevented");
// prevent submit
event.preventDefault();
return false;
}
console.log("submitted");
});
</script>
<textarea rows="30" cols="85" id="content" name="content" placeholder="Write the article here. Try to abide by the instructions and keywords provided."></textarea>
<br />
<input type="submit" name="submitarticle" value="Submit Article" class="submit" />
<br /><br /><br /><br /><br />
</form>