hunter13605
Technical User
Is there a way to limit the number of words allowed? I am able to limit the number of characters but not sure how (or if it is possible) to limit the number of words.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
@words = split(/\s+/,$textbox);
print "Error: Too many words" if (@words > 200);
function Validator() {
// get the text box's value
var txt = document.formname.fieldname.value;
// split into words
var words = txt.split(" ");
// count words
if (words.length > 200) {
window.alert ("Too many words!");
return false;
}
return true;
}
........
<form name="formname" action="handler.cgi" onSubmit="Validator()">
<input type="text" name="fieldname">
<!-- or textarea or whatever it is -->