how i can use onblur function in cakephp form?

632 Views Asked by At

I have written this validation rule in Model but want to validate form data without pressing submit button.

Code:

public $validate = array( 'title' => array( 'rule' => 'notEmpty' ) );

Do i need to put these rules in function to apply javascript?

1

There are 1 best solutions below

0
On BEST ANSWER

without pressing button and for processing you can do this with java script, like

<script>
    var input = document.getElementsByName('title')[0];

    input.onfocus = function() {
        (or do anything else what you need)
        this.className = 'some_class_name';
    }

    input.onblur = function() {
        (or do anything else what you need)
         this.className = '';
    }
</script>

Or with jQuery or any another library used for project