Try this:^((.+
){0,4}.+|.{1,375})$
$(document).ready(function() {
$("#text_string").focusout(function() {
var res, text_string = $("#text_string").val();
if (text_string != null) {
res = text_string.match(/^((.+
){0,4}.+|.{1,375})$/);
console.log(res);
if (!res) {
$("#text_string").val("");
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<textarea name="" id="text_string" cols="30" rows="10"></textarea>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…