Is there a way to limit how many words you can use in text area? I have searched the internet and have only found ways you can do it javascript not PHP.

I've always used javascript for this kind of validation as it's more useful client side, not so good for the user to wait for a server round trip only to find they typed too much.

PHP doesn't execute on the client so you can only inspect the length of the text from the text area form element once the form is submitted to the server. But this is more work as if you detect the length is too long now you have to render the form back to client with all the elements filled in as they were when the user submitted it so they don't have to do it over. ASP.NET makes that easy, I don't know if PHP has any tricks for keeping control state.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.