user3150060 user3150060 - 1 year ago 423
PHP Question

How to validate words count in laravel

I am trying to see how can I validate words count in laravel , for example if a text area accepts only 250 words?

Could some one help me I am using laravel 4.1


Answer Source

I don't think Laravel has a speciic method for this, but you can do it with some simple php.

In your controller:

public function store(){

    $text = Input::get('textarea');

    if(count(explode(' ', $text)) > 250)
        return 'more than 250 words';

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download