user3150060 user3150060 - 11 months ago 212
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



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';